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

    Animated Information Bar

    Hi!

    I installed the Animated Information Bar found on http://www.javascriptkit.com/script/.../infobar.shtml

    Now there is a option to display the bar once per session but this isn't working...

    Code:
    infobar.setfrequency('session') //Uncomment this line to set information bar to only display once per browser session!

    Anyone has installed this bar and knows why this isn't working?
    I use IE8

    greetings
    Jardin
    Holland

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    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">
    
    #informationbar{
    position: fixed;
    left: 0;
    width: 100%;
    text-indent: 5px;
    padding: 5px 0;
    background-color: lightyellow;
    border-bottom: 1px solid black;
    font: bold 12px Verdana;
    }
    
    * html #informationbar{ /*IE6 hack*/
    position: absolute;
    width: expression(document.compatMode=="CSS1Compat"? document.documentElement.clientWidth+"px" : body.clientWidth+"px");
    }
    
    </style>
    
    <script type="text/javascript">
    
    /***********************************************
    
    * Animated Information Bar- by JavaScript Kit (www.javascriptkit.com)
    * This notice must stay intact for usage
    * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more
    
    ***********************************************/
    
    function informationbar(){
    	this.content='<a href="javascript:informationbar.close()"><img src="close.gif" style="width: 14px; height: 14px; float: right; border: 0; margin-right: 5px" /></a>'
    }
    
    informationbar.prototype.setContent=function(data){
    	this.content=this.content+data
    	document.write('<div id="informationbar" style="top: -500px">'+this.content+'</div>')
    }
    
    informationbar.prototype.animatetoview=function(){
    	var barinstance=this
    	if (parseInt(this.barref.style.top)<0){
    		this.barref.style.top=parseInt(this.barref.style.top)+5+"px"
    		setTimeout(function(){barinstance.animatetoview()}, 50)
    	}
    	else{
    		if (document.all && !window.XMLHttpRequest)
    		this.barref.style.setExpression("top", 'document.compatMode=="CSS1Compat"? document.documentElement.scrollTop+"px" : body.scrollTop+"px"')
    	else
    		this.barref.style.top=0
    	}
    }
    
    informationbar.close=function(){
      document.getElementById("informationbar").style.display="none"
      if (cookie&&cookieset){
       cookieset(new Date().getDate())
      }
    }
    
    informationbar.prototype.initialize=function(session){
      if (cookie&&cookie()&&cookie()==new Date().getDate()+''&&session){
       return;
      }
      else {
    		this.barref=document.getElementById("informationbar")
    		this.barheight=parseInt(this.barref.offsetHeight)
    		this.barref.style.top=this.barheight*(-1)+"px"
    		this.animatetoview()
    	}
    }
    
    window.onunload=function(){
    	this.barref=null
    }
    
    
    function cookie(){
      var re=new RegExp('informationbar'+'[^;]+','i');
      if (document.cookie.match(re)){
       return document.cookie.match(re)[0].split("=")[1];
      }
      return null
     }
    
    function cookieset(date){
      document.cookie='informationbar'+'='+date+';expires='+(new Date(new Date().getTime()+1*86400000).toGMTString())+';path=/';
     }
    
    </script>
    <script type="text/javascript">
    
    var infobar=new informationbar();
    infobar.setContent('Welcome to JavaScript Kit! It appears you are not registered yet on our site. Why wait? <a href="#">Register here</a>')
    infobar.initialize(true); // true = once a day, false = always
    
    </script>
    
    
    </head>
    
    <body>
    
    
    </body>
    
    </html>
    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/

  • #3
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the quick reply!

    I tested your code but it isn't working under IE8...
    The cookie isn't set (my browser cookies are unabled)..and the close button isn't working..
    In what browser have you tested your code?

    regards
    Jardin


  •  

    Posting Permissions

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