1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I create popup in Wordpress?

Discussion in 'Blogging' started by invest207, Sep 11, 2009.

  1. invest207

    invest207 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 20, 2008
    Messages:
    543
    Likes Received:
    70
    Location:
    Mars
    I am getting lot of traffic in my blogs but few of them click my affiliate banners.
    I need a WP plugin that when a visitor tries to close my page a 520x750 banner would appear forcing him to visit the aff page or close the popup.

    I found a WP plugin called Exit Rescue but only shows visitor a small window asking him if he would like to visit my link or not.

    Also I am interested if there is a way that another page could be opened in new window when someone visits my page.
     
  2. SpiderWebMaster

    SpiderWebMaster Power Member

    Joined:
    Jan 24, 2009
    Messages:
    617
    Likes Received:
    519
    Occupation:
    I don't have a job...
    Location:
    /dev/null
    try this... put it in the header or footer and you should be set. ofcourse edit the parts that you need to edit

    Code:
    var Page_Enter;
    var TimeLimit=20;
    var Page_ShowPopOnExit=false;
    var MySiteDomain='YOURSITE.COM';
    
    function XBrowserAddHandlerPops(target,eventName,handlerName) {
      if ( target.addEventListener ) {
        target.addEventListener(eventName, function(e){target[handlerName](e);}, false);
      } else if ( target.attachEvent ) {
        target.attachEvent("on" + eventName, function(e){target[handlerName](e);});
      } else {
        var originalHandler = target["on" + eventName];
        if ( originalHandler ) {
          target["on" + eventName] = function(e){originalHandler(e);target[handlerName](e);};
        } else {
          target["on" + eventName] = target[handlerName];
        }
      }
    }
    
    function InternalLink() {
    	Page_ShowPopOnExit = false;
    }
    
    function PageEnter() {
       Page_Enter=new Date();
    }
    
    function SiteExit() {
       var time_dif;
       var Page_Exit=new Date();
       time_dif=(Page_Exit.getTime()-Page_Enter.getTime())/1000;
       time_dif=Math.round(time_dif);
       if (time_dif<=TimeLimit && Page_ShowPopOnExit==true)
    	{
    	alert('Here is your popup!');
    	}
    }
    
    function LinkConvert()
    {
    var href;
    	var anchors = document.getElementsByTagName('a');
    
    	for(var y=0; y<anchors.length; y++)
    	{
    		href = anchors[y].href.toLowerCase();
    		if (!(href.indexOf("http://")!=-1 && href.indexOf(MySiteDomain)==-1))
    			{
    			anchors[y].clickhandler=InternalLink
    			XBrowserAddHandlerPops(anchors[y],"click","clickhandler");
    			}
    	}
    }
    
    XBrowserAddHandlerPops(window,"load","PageEnter");
    XBrowserAddHandlerPops(window,"load","LinkConvert");
    XBrowserAddHandlerPops(window,"unload","SiteExit");
    Page_ShowPopOnExit=true;
    
    and next time... http://lmgtfy.com/?q=popup+on+page+exit

    :D
     
  3. invest207

    invest207 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 20, 2008
    Messages:
    543
    Likes Received:
    70
    Location:
    Mars

    Your popup is not working. I inserted in the header.php but messed my page.
     
  4. SpiderWebMaster

    SpiderWebMaster Power Member

    Joined:
    Jan 24, 2009
    Messages:
    617
    Likes Received:
    519
    Occupation:
    I don't have a job...
    Location:
    /dev/null
    it's not working outside of the box, you must edit it with your site url and your popup code, that is only the code to make it open on exit without interfering wwith internal links
     
  5. kingbrend

    kingbrend Regular Member Premium Member

    Joined:
    Feb 12, 2008
    Messages:
    427
    Likes Received:
    113
    Home Page: