⬆️ ⬇️

Ampersands in string constants

Do not forget, dear javascript-programmers, in string constants specify the ampersand as "& amp;", and not just as "&". For otherwise, the results will be very browser-dependent:
document.body.innerHTML = "http://example.org/get.php?test";

document.body.innerHTML + = "& ok";

document.body.innerHTML + = "& wonderful";
Result:
Firefox:http://example.org/get.php?test&ok&wonderful
Chrome:http://example.org/get.php?test&wonderful
IE:http://example.org/get.php?test


')

Source: https://habr.com/ru/post/97007/



All Articles