View Full Version : Please Help To Modify Script.
Cheng
12-04-2006, 11:11 AM
Hi Everybody.
Someone please tell me what to change or add to this script below to close the image popup if clicked somewhere in the page.
Here the script:
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
win=window.open(mypage,myname,settings);} And here the link that opens the image popup:
<p><a href="Images/PopUps/nang_paya.html" onclick="NewWindow(this.href,'popup','275','400','no','center');return false" onfocus="this.blur()"><img src="Images/Phra Nang Phaya (1.8).jpg" alt="Nang Paya" width="100" height="149" border="0" /></a></p> I did this before but can't remember how I did it.
Thanks in advance.
Masterskinnie
12-04-2006, 08:42 PM
I do not recognize the script. Sorry!
GhettoT
12-04-2006, 10:19 PM
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
win=window.open(mypage,myname,settings);
onClick="javascript:window.close();">}
The bold is what i added. I am pretty sure that is how you can acomplish this.
Cheng
12-05-2006, 05:45 AM
Hi GhettoT.
Thanks but that's not the right code.
With this code the popup wont open at all.
I remember that it was something similar like this:
<script type="text/javascript">
if (self.opener)
window.onblur=function(){self.close();}
</script> With this script here the popup closes like I want to but there is no content inside the window, but it schould be similar to this:
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
win=window.open('',myname,settings);
win.document.write('<body style="margin:0;padding:0;" onblur="self.close()"><img src="'+mypage+'">');
win.document.close();
}
Thanks again.
GhettoT
12-05-2006, 05:49 AM
OK, this is a long shot and i think will probably not work...(i'm optimistic though) try this:
<a onClick="javascript:window.close();">
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
win=window.open(mypage,myname,settings);
}</a>
I think that would make the whole window a hyperlink to onClick="javascript:window.close();" so it would close... Maybe not though!
Sorry i'm still learning...:o
-GT
Cheng
12-05-2006, 06:02 AM
Hi GhettoT.
No that's not it.
See ths script here is working but only to open an image if I specify an url there is no content inside the popup.
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
win=window.open('',myname,settings);
win.document.write('<body style="margin:0;padding:0;" onblur="self.close()"><img src="'+mypage+'">');
win.document.close();
}
Masterskinnie
12-14-2006, 06:35 PM
If so maybe I can help
Put the url on a seperate link as that of the image
Cheng
12-15-2006, 02:32 PM
Hi Masterskinnie.
Thanks for your reply.
I'm not sure if I understand you correctly but if you mean to use a text link instaed of the image as a link to the URL that is not working.
If you meant something else than that please let me know and explain it a little better so I can try it out.
Thanks again.
Masterskinnie
12-15-2006, 04:23 PM
I mean if you are using the pop-it menu at the url http://www.dynamicdrive.com/dynamicindex1/popit.htm
then you should have what looks like this
linkset[0]='<a href="http://www.west-bend.k12.ia.us">Home</a>'
linkset[1]='<a href="http://www.west-bend.k12.ia.us/wbmnew/announcements/dailyannouncements.htm">HS Announcements</a>'
linkset[1]+='<a href="http://www.west-bend.k12.ia.us/wbmnew/msannouncements/msba.htm">MS Announcements</a>'
linkset[1]+='<a href="http://www.west-bend.k12.ia.us/wbmnew/announcements/Decembermenu.html">December Lunch Menu</a>'
What you should do in this case is to do this:
linkset[?your number here?]='<a href="?url here?"><img src="your image name here"></a>'
linkset[?same number?]+='<a href="?same url?>"text here"</a>'
Both the image and the regular link will go to the same page and both are on there though they are both considered separate links by the script
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.