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.
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Philip M View Post
    The OP wanted the splash screen to be shown 3 times only (over multiple sessions). He asked his question in the Javascript forum, and Javascript can very easily do this using a cookie. It is silly to raise the question of Javascript or cookies being disabled.
    The op didn't specify if it was over multiple sessions or not, hence the questions from Labrar and I.

    Obviously Labrar doesn't think it's silly to ask what the op intends to do if javascript or cookies are disabled either. If you do this server side it will work in at least the cases it would work in javascript but if you do it with javascript it will not work in all browsers where it will still work if coded in php, at least for a single session.

    So it's a no brainer, if you want to maximise the possible browsers this will work in then do it server side otherwise javascript is fine if you can accept it working in fewer browsers.

  2. #17
    New Coder
    Join Date
    May 2008
    Posts
    36
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks for this great discussion. I am the OP and I don't have a problem with cookies being turned off or cleared, that would just give me more exposure to my offer. Currently the splash screen never goes away. I am hoping that someone can give me specific code to use as I am not a programmer, or point me to somewhere I can create it. If someone will do this for a fee I'd be happy to pay. Thaks,
    Rich

  3. #18
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,022
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Here you are:-

    <script type = "text/javascript">

    var visits = getCookie("visitscounter");
    if (!visits) {visits = 0}
    visits = Number(visits) + 1;
    alert (visits); // for testing
    var expdate = new Date ();
    expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); // cookie expires 365 days ahead
    setCookie("visitscounter", visits, expdate);

    if (visits <= 3) {
    // code to show splash screen here
    }

    function setCookie(isName,isValue,dExpires) {
    document.cookie = isName + "=" + isValue + ";expires=" + dExpires.toGMTString() ; // path not specified so cookie only active for this page
    }

    function getCookie(isName){
    cookieStr = document.cookie;
    startSlice = cookieStr.indexOf(isName+"=");
    if (startSlice == -1) {return false}
    endSlice = cookieStr.indexOf(";",startSlice+1)
    if (endSlice == -1){endSlice = cookieStr.length}
    isData = cookieStr.substring(startSlice,endSlice)
    isValue = isData.substring(isData.indexOf("=")+1,isData.length);
    return isValue;
    }

    </script>

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  4. Users who have thanked Philip M for this post:

    reach100 (11-28-2012)

  5. #19
    New Coder
    Join Date
    May 2008
    Posts
    36
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Thanks, what do I put here?

    Thank you for your response. What do I put where is says "// code to show splash screen here." I really appreciate your help.

    I did some research and ented this:


    if (visits >= 3) {
    window.location.href = 'http://www.sealfit.com/hp';
    }

    Its working, thanks!
    Last edited by reach100; 11-28-2012 at 01:00 AM.

  6. #20
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,022
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Quote Originally Posted by reach100 View Post
    Thank you for your response. What do I put where is says "// code to show splash screen here." I really appreciate your help.

    I did some research and ented this:


    if (visits >= 3) {
    window.location.href = 'http://www.sealfit.com/hp';
    }

    Its working, thanks!
    Presumably it should be if(visits >3) {

    I understand that you are redrecting to another page (without splash screen) if visits value is more than 3.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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