Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2008
    Location
    New Jersey
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    To have a pop-up when page is opened

    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,732
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    More or less like this:-


    Code:
    <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 =
    'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
    win = window.open(mypage,myname,settings)
    }
    
    </script>

    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.

  • #3
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    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.
    Code:
    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.availHeight,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!');
    		document.location=u;
    	}
    	return false;
    }
    Last edited by eak; 09-15-2008 at 10:51 PM.
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,732
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by eak View Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •