I have some javascript that people paste into web pages. It makes use of a function that accepts a url string as an argument e.g.
function foo(url){
document.location=url;
}
foo('/test.html?boo=1©=2');
However for 'some' people pasting the code into their web page the & in the string is being treated as an entity resulting in the pasted in function call becoming:
foo('/test.html?boo=1@=2');
I thought that it was safe to use & inside javascript blocks? Maybe its their editors or something?
In any case it happens sometimes and I need to fix it. Is it safe to use & in the function call code paste instead of & i.e
foo('/test.html?boo=1&copy=2');
That effectively means this is being done
document.location='/test.html?boo=1&copy=2';
and didn't think you should do that in the javascript code
I am getting more confused the more a think about it!