Forum Moderators: open
var googleButton = document.getElementById('googleButton');
googleButton.onclick = function () {
document.location.href = 'http://www.google.com?foo=1&bar=2';
};
If the value is going to appear within an HTML document (as is the case above), the & needs to be escaped as &
<script type="text/javascript">
var googleButton = document.getElementById('googleButton');
googleButton.onclick = function () {
document.location.href = 'http://www.google.com?foo=1&bar=2';
};
</script>
So as inline javascript appears 'within' a HTML document you need to escape the & in that too?