Opening new window and writing to it on Firefox 1.5 does not complete

Y

Yashesh Bhatia

Hello:

I'm stuck with a small problem using windows created using
javascript.
Here's the code of the html file.

------------------------------------------------------------------------------------------------------
<html>
<head>
<title>Today's Date</title>
<script type="text/javascript">
function print_todays_date() {
var d = new Date(); // get today's date.
document.write(d.toLocaleString());
}
</script>
</head>
<body>
The date and time are: <br/>
<script type="text/javascript">print_todays_date();</script>
<script type="text/javascript">
w1 = window.open();
w1.document.write("Hello World");
</script>
</body>
</html>
------------------------------------------------------------------------------------------------------

Now in the above when i load the html page in FF 1.5 the date is
printed fine.
Also, a new window is opened with the text "Hello World", but the
window
cursor for the new window shows the the document is not loaded
completely.
Also, there's a partial blue bar at the bottom right of the new window
indicating
the page is not loaded completely.

I'd appreciate if anyone can point to the problem as to why the new
window
does not finish loading completely ?

Thanks a lot in advance.

Yashesh Bhatia
 
A

ASM

Yashesh Bhatia a écrit :
Also, a new window is opened with the text "Hello World", but the
window
cursor for the new window shows the the document is not loaded
completely.

<script type="text/javascript">
w1 = window.open();
w1.document.open();
w1.document.write("Hello World");
w1.document.close(); // stops navigator waiting more loading
</script>
 
L

Lee

Yashesh Bhatia said:

If you open it, close it.
Also note that there's no guarantee that a new window will
have a document object to write into so soon after the open()
call:
------------------------------------------------------------------------------------------------------
<html>
<head>
<title>Today's Date</title>
<script type="text/javascript">
function print_todays_date() {
var d = new Date(); // get today's date.
document.write(d.toLocaleString());
}
</script>
</head>
<body>
The date and time are: <br/>
<script type="text/javascript">print_todays_date();</script>
<script type="text/javascript">
w1 = window.open();
w1.document.write("Hello World");
w1.document.close();

</script>
</body>
</html>
-


--
 
R

Randy Webb

Lee said the following on 1/16/2007 10:12 AM:
Yashesh Bhatia said:

If you open it, close it.
Also note that there's no guarantee that a new window will
have a document object to write into so soon after the open()
call:

Along with:

There is no guarantee that a call to window.open that is not user
initiated (as in this instance) will even result in a new window.
 
D

dd

Randy said:
There is no guarantee that a call to window.open that is not user
initiated (as in this instance) will even result in a new window.

I see this sooooo many times out in the wild. People get a
handle to a new popup and don't check whether it exists
before trying to use it. It's one of the downfalls of always
having IE set to show the debug dialog.

Popup blockers people - get used to them.
 

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,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top