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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript fadeout + Remember user input

    Hello, Thanks for reading this and i hope you can help me today

    Right, I have a forum [Dhgaming.com] And have many affiliate sites which require the user to vote for the particular affiliate to put the sites rank up. This will ofcorse help people looking for our web site on the affiliates site. But to the point.

    I would like it so that when the index page is loaded the screen is grayed out something like this

    http://codingatlas.wordpress.com/200...he-user-input/

    But i don't want to anoy the hell out of my users, and would like to make the script so that it only appears once every 25 hours. I'm assuming this would be needed to be done with Cookies but i don't have a clue how.

    If someone is willing to help me, or even make a script for me. It would be really apricated.

    Thanks : )

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,524
    Thanks
    3
    Thanked 508 Times in 495 Posts
    I'm assuming you only want the cookie code

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    function zxcCreateCookie(zxcnme,zxcv,zxcdays){
     document.cookie=zxcnme+'='+zxcv+';expires='+new Date(new Date().getTime()+zxcdays*86400000).toGMTString();+';path=/';
    }
    
    function zxcReadCookie(zxcnme){
     zxcnme+='=';
     var zxcsplit = document.cookie.split(';');
     for(var zxc0=0;zxc0<zxcsplit.length;zxc0++) {
      var zxcs=zxcsplit[zxc0];
      while (zxcs.charAt(0)==' ') zxcs=zxcs.substring(1,zxcs.length);
      if (zxcs.indexOf(zxcnme)==0) return zxcs.substring(zxcnme.length,zxcs.length);
     }
     return null;
    }
    
    function zxcRestore(zxcnme,zxchrs){
     var zxctime=new Date().getTime();
     var zxcv=zxcReadCookie(zxcnme);
     if (!zxcv||zxctime/1000/60/60-zxcv/1000/60/60>zxchrs){
      alert('call your function to show the panel');
      zxcCreateCookie(zxcnme,zxctime,1);
     }
    }
    /*]]>*/
    </script></head>
    
    <body onload="zxcRestore('zxcnme11',25)">
    </form>
    
    </body>
    
    </html>
    with a simple mask

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <style type="text/css">
    /*<![CDATA[*/
    body {
      height:2000px;margin-Top:0px;margin-Left:0px;
    }
    
    .mask {
      position:absolute;visibility:hidden;top:0px;left:0px;width:100%;text-Align:center;background-Color:red;
    }
    
    /*]]>*/
    </style><script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    function zxcCreateCookie(zxcnme,zxcv,zxcdays){
     document.cookie=zxcnme+'='+zxcv+';expires='+new Date(new Date().getTime()+zxcdays*86400000).toGMTString();+';path=/';
    }
    
    function zxcReadCookie(zxcnme){
     zxcnme+='=';
     var zxcsplit = document.cookie.split(';');
     for(var zxc0=0;zxc0<zxcsplit.length;zxc0++) {
      var zxcs=zxcsplit[zxc0];
      while (zxcs.charAt(0)==' ') zxcs=zxcs.substring(1,zxcs.length);
      if (zxcs.indexOf(zxcnme)==0) return zxcs.substring(zxcnme.length,zxcs.length);
     }
     return null;
    }
    
    function zxcRestore(zxcnme,zxchrs,zxcid,zxcopc){
     var zxctime=new Date().getTime();
     var zxcv=zxcReadCookie(zxcnme);
     if (!zxcv||zxctime/1000/60/60-zxcv/1000/60/60>zxchrs){
      var zxcobj=document.getElementById(zxcid);
      zxcOpacity(zxcobj,zxcopc);
      zxcobj.style.height=document.body.scrollHeight+'px';
      zxcobj.style.visibility='visible';
      zxcCreateCookie(zxcnme,zxctime,1);
     }
    }
    
    function zxcOpacity(zxcobj,zxcopc){
     if (zxcopc<0||zxcopc>100) return;
     zxcobj.style.filter='alpha(opacity='+zxcopc+')';
     zxcobj.style.opacity=zxcobj.style.MozOpacity=zxcobj.style.KhtmlOpacity=zxcopc/100-.001;
    }
    
    
    /*]]>*/
    </script></head>
    
    <body onload="zxcRestore('zxcnme2',25,'tst',10)">
    text
    
    <div id="tst" class="mask" >
    <input name="" />
    </div>
    <div style="height:2000px;" >for test page height</div>
    
    </body>
    
    </html>
    Last edited by vwphillips; 10-03-2008 at 09:51 AM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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