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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    2 sites to have pop-up on entry, then not show again

    I'm making 2 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 any pre-made java or other 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

  • #2
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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?

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,981
    Thanks
    56
    Thanked 557 Times in 554 Posts
    you don't really need to use cookies (and people disable them anyway) - you can do this very simply using query strings in the links on the page. maybe this will help:

    Code:
    <script type="text/javascript">
    var intro = self.location.search;
    if (intro=="?refer"){
    alert("you don't need to see the intro");
    } else {
    alert("here's the intro");
    }
    </script>
    
    <body>
    <div> 
    <a href="page2.htm?refer" target="_self">go to page 2</a>
    </div>
    </body>
    Last edited by xelawho; 09-10-2011 at 09:24 PM. Reason: general housekeeping

  • Users who have thanked xelawho for this post:

    effectivesite (09-10-2011)

  • #4
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    that's perfect thanks!
    Hadn't thought of doing that, definitely the simplest method though.
    thank you very much.

  • #5
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,981
    Thanks
    56
    Thanked 557 Times in 554 Posts
    you're welcome.

    I realised, though, looking back on it that the first two lines could be simplified into:
    if (self.location.search=="?refer"){

    if you're into that sort of thing.


  •  

    Posting Permissions

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