[Javascript] window.open() not working in onLoad() of Mozilla 1.5

David Lovering dlovering at gazos.com
Sat May 1 08:11:55 CDT 2004


First off, the onLoad function documentation rather explicitly states that
the first parameter is an HTML file name, or a pointer to a file (with
whatever extension) that encapsulates an HTML page.  Of course, many things
which are explicitly stated in the W3C docs I have found to be erroneous on
one platform or another, so you can take it or leave it.

The other thing I found problematic is the "location=no" declaration.  In
some of my tests this caused difficulties in the onLoad, but only for some
browsers with certain revision/version combinations.  Go figure.

If I were you, I'd sneak up on it.  Start by changing the onLoad to simply
launch an alert, i.e;

<body onLoad='javascript:alert("howdy, yall!");'>

And see if it works cross-platform.  Then try explicitly building the
javascript function winOpen to just open a window (no embedded code
reference), and launch it from onLoad.  Then if that works cross-platform,
try building an HTML file which is just a wrapper for your javascript code
originally contained in newwindow.jsp.  If that works, you've got the
functional equivalent of your original design.

If any of these don't work cross-platform, then I'd try to use
document.write declarations to build the working code you wanted in
newwindow.jsp inside the winOpen function.  Ugly as sin, but it might work
where other methods fail.  If you don't want to descend to quite this
primitive a level, you can always do a javascript src include to bring your
newwindow.jsp code into a window in process.

At least that's how I'd do it.

-- Dave Lovering
----- Original Message ----- 
From: "Antony Paul" <antonypaul24 at hotmail.com>
To: "JavaScript" <javascript at LaTech.edu>
Sent: Saturday, May 01, 2004 12:35 AM
Subject: [Javascript] window.open() not working in onLoad() of Mozilla 1.5


> Hi all,
>   I have problem in opening a new window from the onLoad() event of the
body
> in Mozilla 1.5. It is calling another function which opens a new window.
If
> I call the function in a button click it works.
> This is syntax I used
> var x = window.open("newwindow.jsp","name","toolbar=no,location=no");
>
> It is invoked in onLoad();
> <body onLoad="winOpen()">
>
> what is wrong with it. It is not giving any error in the JavaScript
console.
>
> Antony Paul
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>





More information about the Javascript mailing list