Mozilla 1.5 can't create a window from onLoad event in <body> tag?

Discussion in 'Javascript' started by Starry Gordon, Feb 3, 2004.

  1. I've been running some small test programs which seem to indicate
    something noticed in a larger script, that a function called from
    onLoad() in the <body> tag will not succeed in creating a window
    (i.e. successfully executing window.open() in Mozilla 1.5; however,
    I've observed it to work a few times in IE 6.0 and Opera 5.something.
    It does not seem to be a timing thing -- if I re-call the function
    somewhat later using setTimeout it still doesn't succeed. However,
    a call to the same function from a link (a href=...) does succeed.
    I'm wondering if I've overlooked something in the documentation.

    The shortest of the tests:
    -----------------------------------------------------------------
    <html>
    <head>
    <title>x</title>
    <script language="JavaScript1.2" type="text/javascript">
    var k = 0;
    var m = 'w1.<br>';
    var w1;

    function initz() {
    k += 1;
    if (w1) {
    m += k + ": already here! ";
    } else {
    m += k + ": opening... ";
    w1 = window.open(" ", "w1",
    "toolbar=no,status=yes,height=400,width=400,menubar=yes,scrollbars=yes,resizable=yes,directories=no,location=no");
    }

    if (!w1) {
    m += k + ": not here.... ";
    } else {
    m += k + ": here! ";
    w1.document.write("m=" + m + "<br>");
    }
    }
    </script>
    </head>

    <body bgcolor='#53438F' text='#ffff00' link='#ff0000' vlink='#cc0000'
    onload='javascript:initz()'>
    <a href='javascript:initz()'>
    xxx</a>
    </body>
    </html>
    -----------------------------------------------------------------

    which, when the link is clicked on, brings up a window with
    the following text:

    m=w1.
    1: opening... 1: not here.... 2: opening... 2: here!
    Starry Gordon, Feb 3, 2004
    #1
    1. Advertising

  2. Starry Gordon

    DU Guest

    Re: Mozilla 1.5 can't create a window from onLoad event in <body>tag?

    Starry Gordon wrote:

    [snipped]

    a function called from
    > onLoad() in the <body> tag will not succeed in creating a window


    [snipped]

    Thank god I don't have to endure such poor webpage design anymore: I
    block unrequested popups and so do millions of others using browsers (or
    add-ons) suppressing such nonsense.

    DU
    DU, Feb 3, 2004
    #2
    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. ~~~ .NET Ed ~~~
    Replies:
    5
    Views:
    1,342
    David Wainwright
    Mar 27, 2007
  2. Jason
    Replies:
    4
    Views:
    1,591
    Jason
    May 7, 2007
  3. Bender
    Replies:
    2
    Views:
    249
    Thomas 'PointedEars' Lahn
    Oct 22, 2003
  4. David Otton

    window.onload and body.onload differences

    David Otton, Nov 4, 2004, in forum: Javascript
    Replies:
    2
    Views:
    532
    Martin Honnen
    Nov 4, 2004
  5. Replies:
    18
    Views:
    526
Loading...

Share This Page