Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup photo window works once only in Mac's Safari

Status
Not open for further replies.

leehinkleman

Programmer
Feb 14, 2002
83
NZ
The following code works ok in IE4+ and Mozilla Firebird in Linux, but works once only in Konqueror on Linux, and I've been told it works once only for Safari on Macs.
The arguments for function wO() are (this,name,width,height)
just so I could use the name of trout fly patterns to make simple links to their .jpg images.
The variable bl has an initial value of 0 and is re-assigned a value of 1 when the page body loads.
function X() was intended to keep only 1 popup window at a time on top of the main window. For that idea, I tried re-assigning a another variable from 0 to 1 when the body of the popup page unloaded, to try to determine if a popup window was already open, but then all the photo popups seemed to fail in IE6.
Could someone please tell me why this javascript is failing in Safari and Konqueror? Thanks for your help.

pup="";
function X(){
if(pup!=""){
pup.close();
}
}
bl=0;
function wO(tl,n,w,h){
if(bl<1){
tl.blur();
return;
}
X();
t=n.replace(/_/g," ");
wp=w+20;
hp=h+40;
n="z='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+wp+',height='+hp;
pup=window.open('','',z);
with(pup.document){
writeln('<html>');
writeln('<head><title>'+t+'</title></head>');
writeln('<body>');
writeln('<center><img src="'+n+'" width='+w+' height='+h+' alt="'+t+' trout fly"><br><b>'+t+'</b></center>');
writeln('</body>');
writeln('</html>');
close();
}
pup.focus();
}
 

Immediately after this code:

Code:
with(pup.document){

try putting this code:

Code:
open();

You should also be able to replace this line:

Code:
z='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+wp+',height='+hp;

with this line:

Code:
z='width='+wp+',height='+hp;

as the items with "no" next to them should be turned off by default.

Hope this helps,
Dan
 
Thanks, Dan! Using pup.document.open() again before the pup.document.writeln-ing has made it work in Konqueror, and I'm confident it will work now with Safari, too.
Thanks again.
Sincerely,
Lee
 

The document.open() thing is something that's I've been using since NN4.7... Maybe we'll see more of it with these newer browsers now, too.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top