I have a code to open new window and display a progress bar .The code works fine in I.E and Netscape4.7 but in Netscape 7.2 it opens a new window and displays nothing in it . Below is my code. Can you please tell me what is wrong in my code.

<html>
<script> 
var Window02; 
var secondWindow = false;
function ProgressBar(sLength) { 
var BarLength = 88; 
var iLength = parseFloat(sLength); 
var Bar = parseInt(iLength); 
var Trough = parseInt(BarLength - iLength); 
if (secondWindow == false) 
{ 
var theWindow = 'width=700,height=60,left=10,top=20,menubar=0,toolbar=0,location=0,personalbar=0,status=0,scrollbars =0,directories=0,resizable=0';
Window02 = window.open('', 'Wind02', theWindow); 
} 
if (secondWindow == false) 
{ 
Window02.document.write('<html><body><form name=f1>' + 
'<input type="text" size="' + Bar.toString() + '" style="background:blue">' +
'<input type="text" size="' + Trough.toString() + '" style="background:green">' +
'Page is loading.' +
'</form></body></html>');
secondWindow = true; 
Window02.document.close();
} 
if (secondWindow == true) 
{ 
Window02.document.write('<html><body><form name=f1>' + 
'<input type="text" size="' + Bar.toString() + '" style="background:blue">' +
'<input type="text" size="' + Trough.toString() + '" style="background:green">' +
'Page is loading.' +
'</form></body></html>');
Window02.document.close();
}
} 
function BarRun() 
{ 
for(i=0;i<50;i++)
{ 
ProgressBar(i);
BarDelay(1000); 
} 
Window02.close(); 
secondWindow = false; 
}
function BarDelay(msec) { 
var enter_date = new Date();
var enter_time = enter_date.getTime(); 
var leave_date = new Date(); 
var leave_time = leave_date.getTime(); // a big integer 
while (enter_time + msec > leave_time) { 
leave_date = new Date(); leave_time = leave_date.getTime(); } 
}
</script> 
<body> 
<form name=f1> 
<input type=button value=showProgressbar onClick=BarRun()>
</form>
</body>
</html>

Recommended Answers

All 3 Replies

you need to use Window02.document.open() before there is a valid document to write to in netscape and mozilla.

Thanks for your reply.
I added Window02.document.open() before Window02.document.write
but it doesn't help. If i remove the Window02.close() then I see that after sometime it displays the last position of the progress bar in the window. I read somewhere that this could be a multithreading issue and javascript doenot support multithreading.
Is there any other way a progressbar can be displayed ,it neednot be in a popup window?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.