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

Discussion in 'Javascript' started by Vincent van Beveren, Jan 7, 2005.

  1. 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 van Beveren, Jan 7, 2005
    #1
    1. Advertising

  2. 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?

    > eval(s);


    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?




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 7, 2005
    #2
    1. Advertising

  3. Vincent van Beveren

    eric Guest

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

    Vincent van Beveren wrote:
    > 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>
     
    eric, Jan 7, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmljayBTaHVyaQ==?=

    WebControls.Menu in Whidbey not Mozilla compatible?

    =?Utf-8?B?UmljayBTaHVyaQ==?=, Mar 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    394
    Brian Henry
    Mar 12, 2005
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,234
    Smokey Grindel
    Dec 2, 2006
  3. imagina
    Replies:
    3
    Views:
    312
    imagina
    Feb 22, 2004
  4. webdev
    Replies:
    3
    Views:
    105
    Michael Winter
    Oct 10, 2004
  5. pantagruel
    Replies:
    0
    Views:
    271
    pantagruel
    Feb 17, 2006
Loading...

Share This Page