Forum Moderators: open
In an effort to achieve W3C validation for XHTML, all ampersands have to used in the form & and this is causing strange behaviour in FireFox browser. The following PHP script generates some JavaScript code.
if (empty($js_enabled)) {
if (strpos($REQUEST_URI, "?")) $REQUEST_URI .= "&js=y";
else $REQUEST_URI .= "?js=y";
$js_selflocation = $REQUEST_URI;
$js_selflocation = str_replace("&", "&", $js_selflocation);
$javascript_message =<<<JS
<script language='JavaScript' type='text/javascript'>
self.location='$js_selflocation';
</script>
JS;
The JavaScript code looks like this:
<script language='JavaScript' type='text/javascript'>
self.location='/product.php?productid=9175&js=y';
</script>
Everything works fine in IE 5 and 6, but in any version of FireFox the browser url will start off with one "&js=y" and then the URL keeps refreshing with an additional "&js=y" appended to the end of the URL. The browser gets stuck in an infinite loop.
Is there anything else I can replace the & with? I've seen some code samples using hex %26 but this is not converted to an ampersand in the URL itself. I would prefer the ampersand to display as normal.
Many thanks in advance.
--
Regards,
Asim
You can get around this in two ways without changing the "&" to "&"...
1. put the javascript in an external file, or
2. use... //<![CDATA[
<script type="text/javascript">
//<![CDATA[
self.location='/product.php?productid=9175&js=y'
//]]>
</script>
birdbrain
No problem, you're very welcome. ;)