MetroidHacker
Programmer
I'm having trouble with some code that behaves differently in Internet Explorer 6 and 7.
In IE6, this replaces the document with one line, "Hello, world!", but in IE7, the "Hello, world!" is rolled into the rest of the page and comes out between "Test" and the URL of the original page. The following code has exactly the same effect:
and replacing document.URL with window.location.href also has the same effect.
It seems strange to set a variable and then read it back, only to find its value has not been changed. The problem seems to be with the handling of the "javascript:" protocol, because using a URL such as " redirects to the website in both browsers, but running javascript has different behavior in the two browsers. I need to replicate IE6's behavior in IE7. Any ideas, anyone?
Code:
<html>
<body>
<p>Test</p>
<script language=javascript>
window.location.replace("javascript:document.write(\"<p>Hello, world!</p>\")");
document.write(window.location);
</script>
</body>
</html>
In IE6, this replaces the document with one line, "Hello, world!", but in IE7, the "Hello, world!" is rolled into the rest of the page and comes out between "Test" and the URL of the original page. The following code has exactly the same effect:
Code:
<html>
<body>
<p>Test</p>
<script language=javascript>
document.URL="javascript:document.write(\"<p>Hello, world!</p>\")";
document.write(document.URL);
</script>
</body>
</html>
and replacing document.URL with window.location.href also has the same effect.
It seems strange to set a variable and then read it back, only to find its value has not been changed. The problem seems to be with the handling of the "javascript:" protocol, because using a URL such as " redirects to the website in both browsers, but running javascript has different behavior in the two browsers. I need to replicate IE6's behavior in IE7. Any ideas, anyone?