Why does this not work in IE, but in Mozilla (and compatible)

  • Thread starter Vincent van Beveren
  • Start date
V

Vincent van Beveren

I have the following (seemingly) useless piece of JavaScript

<html>
<head>

<script type="text/javascript">
function frameMe() {
s = "document.open();";
s += "document.writeln('<html><frameset rows=\"*,33%\">');\n";
s += "document.writeln('<frame src=\"' + document.location +
'\">');\n";
s += "document.writeln('<frame src=\"about:blank\">');\n";
s += "document.writeln('</frameset></html>');\n";
eval(s);
}
</script>

</head>

<body>
<input type="button" onClick="frameMe();" value="Frame me! (again?)">
</body>
</html>

Now, in Firefox this works fine, but in IE, it doesn't. Does anyone
know why, and if it can be helped?

Thanks,
Vincent
 
M

Martin Honnen

Vincent van Beveren wrote:

<html>
<head>

<script type="text/javascript">
function frameMe() {
s = "document.open();";
s += "document.writeln('<html><frameset rows=\"*,33%\">');\n";
s += "document.writeln('<frame src=\"' + document.location +
'\">');\n";
s += "document.writeln('<frame src=\"about:blank\">');\n";
s += "document.writeln('</frameset></html>');\n";

Why no
document.close();
call?

Why the eval, couldn't you simply have the function have
document.open();
document.write(...);
document.close();
calls?
</script>

</head>

<body>
<input type="button" onClick="frameMe();" value="Frame me! (again?)">
</body>
</html>

Now, in Firefox this works fine, but in IE, it doesn't.

Well what happens with IE, do you get a script error, or what exactly
doesn't work?
 
E

eric

Vincent said:
I have the following (seemingly) useless piece of JavaScript

<html>
<head>

<script type="text/javascript">
function frameMe() {
s = "document.open();";
s += "document.writeln('<html><frameset rows=\"*,33%\">');\n";
s += "document.writeln('<frame src=\"' + document.location +
'\">');\n";
s += "document.writeln('<frame src=\"about:blank\">');\n";
s += "document.writeln('</frameset></html>');\n";
eval(s);
}
</script>

</head>

<body>
<input type="button" onClick="frameMe();" value="Frame me! (again?)">
</body>
</html>

Now, in Firefox this works fine, but in IE, it doesn't. Does anyone
know why, and if it can be helped?

Thanks,
Vincent


Vincent,
Hmm...thats kinda neat....never thought of dynamically writing frames,
but it does seem to work. I worked out a way that works for firefox
and IE (see below). I tend to not like using frames since there are
usually other ways to do it without...but if you have some strange need
it could come in handy(I myself might have such a need). Eric

<html>
<head>

<script type="text/javascript">

function frameMe() {
document.write('<html><frameset rows=\"*,33%\"><frame name=\"main\"
src=\"net.htm\"><frame src=\"testme

..htm\"></frameset></html>');
window.frames.main.location="net.htm"
}
</script>

</head>

<body>
<input type="button" onClick="frameMe();" value="Frame me! (again?)">
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top