Code or Plugin to show pop-up on initial visit to one of two sites

Discussion in 'Programming' started by effectivesite, Sep 10, 2011.

  1. #1
    I'm making 2 wordpress sites and need a visitor who lands on the home page of either site to first be shown a page that shows a company introduction and 2 links at the bottom so they can choose which division of the site (which website) they want to go to.

    Does anyone know of a plugin or code that would allow for this? So that a visitor doesn't get stuck in a cycle of being taken from one home page to the other and having the pop-up every time, I'm thinking it will likely need to write a cookie saying they've seen the pop up, then it won't appear again.
    Each site would then have to check for a cookie from either site.

    Does anyone have any ideas on how to make this work? I'm open to anything and have to have it done by friday :eek:
     
    effectivesite, Sep 10, 2011 IP
  2. effectivesite

    effectivesite Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I believe I've found the solution.
    the code is

    -----------------------------------------
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Script courtesy of Web Page Design | Website Design | Website Designing | Web Site Design | Web Site Designing | Web Page Development | Web Development - Your Guide to Professional Web Site Design and Development
    function GetCookie(name) {
    var arg=name+"=";
    var alen=arg.length;
    var clen=document.cookie.length;
    var i=0;
    while (i<clen) {
    var j=i+alen;
    if (document.cookie.substring(i,j)==arg)
    return "here";
    i=document.cookie.indexOf(" ",i)+1;
    if (i==0) break;
    }
    return null;
    }
    var visit=GetCookie("COOKIE1");
    if (visit==null){
    var expire=new Date();
    window.name = "thiswin";
    newwin=open("yourpagename.html", "dispwin",
    "width=450,height=455,scrollbars=yes,menubar=no");
    expire=new Date(expire.getTime()+7776000000);
    document.cookie="COOKIE1=here; expires="+expire;
    }
    // -->
    </SCRIPT>
    -----------------------------------------


    The only thing I'm not sure of is how would I get it to check for a cookie from either of the 2 sites?
    anyone know?
     
    effectivesite, Sep 10, 2011 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    You can't get a cookie from another site - browsers are written to prevent that.

    Just log the first visit in the database. If that user is in the database it's not the first visit, and you've saved the division they chose in the database.
     
    Rukbat, Sep 10, 2011 IP
    effectivesite likes this.
  4. effectivesite

    effectivesite Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks Rukbat.
    That makes sense for the cookies, couldn't find a solution anywhere.
    I'll try writing their ip to a database and going by that.
    Thanks again.
     
    effectivesite, Sep 10, 2011 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    IP logging won't work for mobiles, people using hotspots and providers rotating addresses quickly. But you could combine cookies and a database. Each site sends its own cookie, but you link them in the database. By login if you can, by any other means the sites have. (If there's no way to link them you're limited to IP, but these days that's iffy, and it'll become useless in a decade.)
     
    Rukbat, Sep 10, 2011 IP