Click to See Complete Forum and Search --> : Help with popup script
shimmy
01-28-2003, 06:16 PM
Hey all,
I am trying to add a script to my page that will open a popup window when a link is selected.
The popup window is for another page within my server, I do not want the page to have any menu bars, at all, I only want it to be scrollable and the size needs to be 800x600.
Also, I will have multiple links on the main page and they will all need to open the same as mentioned above, and in seperate windows.
The scripts I have used seem to open 2 pages when the link is selected, the first page points to knowhere, the second page points to the correct link.
I have been pulling my hair out all day for this simple script any help would be great!!
Thanks a lot!!
Shimmy
Ribeyed
01-28-2003, 06:25 PM
hi,
can you post the script plz?
shimmy
01-28-2003, 06:46 PM
the head...
<script language="javascript" type="text/javascript">
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+',l ocation=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->
</script>
The link
<a href="http://www.starchmartins.com/gallery/thumbs" onclick="NewWindow(this.href,'Gallery 1','800','600','yes','center');return false" onfocus="this.blur()">YourLinkText</a>
Ribeyed
01-28-2003, 07:11 PM
Hi,
Javascript not my strong skill, but i had some code i have previously used for a site, maybe you can modify it to your needs. I did notice that i was getting an error in you're page when it was loaded into the browser.
<script language="javascript" type="text/javascript">
function newwindow(theURL,winName,w,h,scrolls) {
var winl = (screen.width - w);
var wint = 0;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrolls+',resizable'
window.open(theURL,winName,winprops);
}
</script>
<a href="http://www.starchmartins.com/gallery/thumbs" onClick="newwindow('sitemap.asp','sitemap','400','100','no');return false;" onfocus="this.blur()">YourLinkText</a>
khalidali63
01-28-2003, 07:22 PM
Your error is in this line.
Originally posted by shimmy
The link
<a href="http://www.starchmartins.com/gallery/thumbs" onclick="NewWindow(this.href,'Gallery 1','800','600','yes','center');return false" onfocus="this.blur()">YourLinkText</a>
what is happening here is that the default onclick event takes over and opens the page and it does not even make it to process NewWindow.
therefore you need to do it this way
try this
<a href="javascript:NewWindow(this.href,'Gallery1','800','600','yes','center');" onfocus="this.blur()">YourLinkText</a>
shimmy
01-28-2003, 10:17 PM
Got it, thanks for your help!!