SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Popup script

  1. #1
    SitePoint Zealot hvoice's Avatar
    Join Date
    Sep 2003
    Location
    New York
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Popup script

    Greetings,

    I have a question. If you go to http://add2it.com and then click on the back button, you will get a little pop up asking for suggestions.

    Now, the popup won't appear again if you return to the site for the 2nd time.

    Any ideas on where to get the code for it?

    Boris
    - PayPerClickUniverse.com - Click Here for exclusive
    deals on Overture, FindWhat, Enhance, Search123 and more.

  2. #2
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They use this code...
    Code:
    <script language="JavaScript"><!--
    var leave=true;
    var windowprops = "width=550,height=400,screenX=60,screenY=60,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,alwaysRaised=yes,marginwidth=0,marginheight=0";
    function page (link) {
    f=open(link, "add", windowprops);
    f.focus();
    }
    function a2is(){
    }
    function a2ie(){
    var leavecookie = "add2itleave";
    if (getOptinCookie(leavecookie) == "") {
    if(leave && document.all) {
    var today = new Date();
    var expdate = new Date(today.getTime() + 30 * 24 * 3600000);
    document.cookie = leavecookie + "=done;expires=" + expdate.toGMTString();
    var _url = "http://www.add2it.com/leave.shtml?" + document.URL;
    showModalDialog(_url,window,'status:no; help:no; dialogWidth:570px; dialogHeight:390px');
    }
    }
    }
    //--></script>
    and they put an onunload event in the body tag...
    Code:
    <body onUnload="a2ie()">

  3. #3
    SitePoint Zealot hvoice's Avatar
    Join Date
    Sep 2003
    Location
    New York
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thank you so much for the advice. However, I tried to set it up at: http://www.adwatcher.net - and for some reason, the popup doesn't load.

    Any ideas why?

    Boris
    - PayPerClickUniverse.com - Click Here for exclusive
    deals on Overture, FindWhat, Enhance, Search123 and more.

  4. #4
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    probably because it takes out all of the onunload functions out of the body tag, I know that by ZoneAlarm does that. You can change it so under the function you have...
    Code:
    window.onUnload=function(){a2ie();}

  5. #5
    SitePoint Zealot hvoice's Avatar
    Join Date
    Sep 2003
    Location
    New York
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry - but where exactly should I add that snippet of code?
    - PayPerClickUniverse.com - Click Here for exclusive
    deals on Overture, FindWhat, Enhance, Search123 and more.

  6. #6
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script language="JavaScript"><!--
    var leave=true;
    var windowprops = "width=550,height=400,screenX=60,screenY=60,toolbar=no,location=no,directories=  no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,alwaysRais  ed=yes,marginwidth=0,marginheight=0";
    function page (link) {
    f=open(link, "add", windowprops);
    f.focus();
    }
    function a2is(){
    }
    function a2ie(){
    var leavecookie = "firstleave";
    if (getOptinCookie(leavecookie) == "") {
    if(leave && document.all) {
    var today = new Date();
    var expdate = new Date(today.getTime() + 30 * 24 * 3600000);
    document.cookie = leavecookie + "=done;expires=" + expdate.toGMTString();
    var _url = "http://www.add2it.com/leave.shtml?" + document.URL;
    showModalDialog(_url,window,'status:no; help:no; dialogWidth:570px; dialogHeight:390px');
    }
    }
    }
    //-->
    window.onUnload=function(){a2ie();}
    </script>

  7. #7
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can change var expdate = new Date(today.getTime() + 30 * 24 * 3600000);
    so it will show the popup sooner, this will add a lot of days before the next time it opens...

  8. #8
    SitePoint Zealot hvoice's Avatar
    Join Date
    Sep 2003
    Location
    New York
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi - I did everything you mentioned on adwatcher.net and it still doesn't work.

    Any ideas why?

    Boris
    - PayPerClickUniverse.com - Click Here for exclusive
    deals on Overture, FindWhat, Enhance, Search123 and more.

  9. #9
    SitePoint Zealot hvoice's Avatar
    Join Date
    Sep 2003
    Location
    New York
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Guys, come on - anyone at all?

    Boris
    - PayPerClickUniverse.com - Click Here for exclusive
    deals on Overture, FindWhat, Enhance, Search123 and more.

  10. #10
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, here is the working code...
    Code:
    <script language="JavaScript"><!--
    function getOptinCookie(cookieName) {
    	var id = cookieName + "=";
    	var cookievalue = "";
    	if (document.cookie.length > 0) {
    		offset = document.cookie.indexOf(id);
    		if (offset != -1) {
    			cookievalue = "x";
    		}
    	}
    	return cookievalue;
    }
    
    function getTestCookie(tcookieName) {
    	var id = tcookieName + "=";
    	var cookievalue = "";
    	if (document.cookie.length > 0) {
    		offset = document.cookie.indexOf(id);
    		if (offset != -1) {
    			cookievalue = "x";
    		}
    	} 
    	return cookievalue;
    }
    function optin(text) {
    	setOptinCookie();
    	if(confirm(text)) {
    		if (forwardURL != "") {
    			window.location.href = forwardURL;
    			setPermanentCookie();
    		} else {
    			document.mailer.subscribe.click();
    		}
    	}
    }
    
    function setTestCookie () {
    	var today = new Date();
    	var expdate = new Date(today.getTime() + 1 * 24 * 3600000);
    	document.cookie = tcookie + "=done;expires=" + expdate.toGMTString();
    }
    
    function setOptinCookie () {
    	var today = new Date();
    	var expdate = new Date(today.getTime() + 1 * 24 * 3600000);
    	document.cookie = cookie + "=done;expires=" + expdate.toGMTString();
    }
    
    function setPermanentCookie () {
    	var today = new Date();
    	var expdate = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); // 1 year
    	document.cookie = cookie + "=done;expires=" + expdate.toGMTString();
    }
    
    var leave=true;
    var windowprops = "width=550,height=400,screenX=60,screenY=60,toolbar=no,location=no,directories=    no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,alwaysRais    ed=yes,marginwidth=0,marginheight=0";
    function page (link) {
    f=open(link, "add", windowprops);
    f.focus();
    }
    
    function a2ie(){
    var leavecookie = "CHANGETHIS";
    if (getOptinCookie(leavecookie) == "") {
    if(leave && document.all) {
    var today = new Date();
    var expdate = new Date(today.getTime() + 30 * 24 * 3600000);
    document.cookie = leavecookie + "=done;expires=" + expdate.toGMTString();
    var _url = "http://www.add2it.com/leave.shtml?" + document.URL;
    showModalDialog(_url,window,'status:no; help:no; dialogWidth:570px; dialogHeight:390px');
    }
    }
    }
    //-->
    
    </script>
    Just change...
    Code:
    var leavecookie = "CHANGETHIS";
    (the bold part) to a better name, this is the cookie that will check if it is the users first time exiting the window.

    Also, change....
    Code:
    var _url = "http://www.add2it.com/leave.shtml?" + document.URL;
    (the bold part) to the URL you want it to pop up when the user leaves.

    You can also change...
    Code:
    showModalDialog(_url,window,'status:no; help:no; dialogWidth:570px; dialogHeight:390px');
    (the bold parts) to make the window different sizes!

  11. #11
    SitePoint Zealot hvoice's Avatar
    Join Date
    Sep 2003
    Location
    New York
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wonderful!!

    By the way, is there any way to avoid the box popping up when a user simply goes to another page on the website?

    Boris
    - PayPerClickUniverse.com - Click Here for exclusive
    deals on Overture, FindWhat, Enhance, Search123 and more.

  12. #12
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ya... To do that, add to your links, and possibly buttons...
    Code:
    onClick="leave=false;"
    so a link could look like...
    Code:
    <a href="http://www.yoursite.com/mypage.php" onClick="leave=false;">CLICK HERE</a>
    the leave=false will tell the scripts that the user is not leaving, just simply clicking a link

  13. #13
    SitePoint Member
    Join Date
    Jul 2004
    Location
    netherlands
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    var _url = "http://www.add2it.com/leave.shtml?" + document.URL;
    I got a question about this, I changed it to the correct url. but when i close window, it says, cant find page. THe link went very strange. it was like /poll/index.phphttp://www.site.com/poll/index.php
    To solve the problem i changed the script by removing the + document.URL;
    that worked. But the problem is now, the url is a php document with a poll in it. When plp vote, the page doesnt refresh, but opens a new window with the results and keeps the voting page open.

    The question is, how to change that? when i open the poll.php page on itself and vote, it refreshes in its own window.


Bookmarks

Posting Permissions

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