...

View Full Version : Animated Information Bar



Jardin
07-30-2011, 12:54 PM
Hi! :)

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

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


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

vwphillips
07-30-2011, 04:29 PM
<!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>

Jardin
07-30-2011, 05:38 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum