php - How do I prevent internet explorer from rewriting my text? -
i have javascript variable contains url, populated outputting script tag php. intention change webpage url under circumstances.
var url = "/somepage?q=3®ion=1";
the problem url contains sequence "®" internet explorer changes "®" without being asked.
i've tried escaping whole url htmlspecialchars, breaks other browsers. turning off quirks mode might help, it's not option current system. adding script tag did nothing.
edit: figured out 1 solution, "escaping" url concatenation.
var url = '<?php implode( "&'+'", explode( '&', '/somepage?q=3®ion=1' ) ); ?>';
i realized should mention how change page:
document.location.href = url;
edit: turns out had error in script tag. minimal example shows same "problem":
<script type="text/javascript" /> var url = "/test?mode=preview®ion=1"; </script> the self-closing start tag important thing here.
it should var url = "/somepage?q=3&region=1";
always use & in urls browser understands query separator , doesn't think refers htmlentity (the problem here ie doesn't care if semicolon present or not , assumes ® should ®)
edit: real context added after answered , pointed out in question , in comments, shouldn't use & if intend use variable redirect using window.location
but, since have php @ hand, suggest using php code if javascript redirect not part of other complex script:
<?php header('location: http://domain/somepage?q=3®ion=1'); exit(); ?>
Comments
Post a Comment