View Full Version : To have a pop-up when page is opened

09-15-2008, 09:04 PM
So here is what I am trying to accomplish. When someone goes to my website I want a pop-up to show up I want it to have a link to another page that has info for that guests. So hopefully this explains it. I need a pop to show up as soon as they enter the site. Can this be done and how is it done. Thank you for help

Philip M
09-15-2008, 10:51 PM
More or less like this:-

<body onload = "NewWindow('http://www.yoursite.com/PopUpPage.html','myPop','600','500','yes')">

<script type="text/javascript">

var win = null;
function NewWindow(mypage,myname,w,h,scroll) {
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
win = window.open(mypage,myname,settings)


Then the page PopUpPage.html includes the link. I don't know what you mean by "has info for that guests (sic)". You can "remember" user details from a previous session with a cookie, but if you want to read info from some kind of database then you will need to use a server-side language.

Following protracted negotiations we have come to an arrangement with the banks under which we have agreed not to supply goods to our customers on credit. For their part the banks have agreed not to sell fishing equipment.

09-15-2008, 11:05 PM
fishmaster0, unrequested popups will most likely be blocked by popup blockers.
You should have a link that opens the NewWindow instead of the onload event.

Also, the NewWindow script Philip M provided is rather old. I made that many years ago.

This is my latest version.

function NewWindow(u,n,w,h,f,p,x,y){
/* Copyright Eric King : http://www.webdeveric.com/ - &copy; 2000 - 2008
This script is free to use for any non profit website as long as this info is left in */
w=(w)?w:sw;h=(h)?h:sh;var ws=window.screen?1:0,m=Math,C='center',R='random',M='custom',sw=screen.availWidth,sh=screen.availHei ght,T=(p==C&&ws||!p)?(sh-h)/2:(p==R&&ws)?(m.floor(m.random()*(sh-h))):(p==M&&h!=sh)?y:0,L=(p==C&&ws||!p)?(sw-w)/2:(p==R&&ws)?(m.floor(m.random()*(sw-w))):(p==M&&w!=sw)?x:0,s='width='+w+',height='+h+',top='+T+',screeny='+T+',left='+L+',screenx='+L;s+=(!f||f=='') ?'':','+f;
var win=window.open((u)?u:'http://www.webdeveric.com/',(n)?n:'',s);
if(win && !win.closed){win.focus();return win;}
if(!win){//alert('popup blocker!');
return false;

Philip M
09-16-2008, 09:20 AM
Also, the NewWindow script Philip M provided is rather old. I made that many years ago.

Yes, you are so right. But it still works! I was not aware of the origin though. :)