Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Play background audio only once per visit and hover button issue

Status
Not open for further replies.

escellentguy

Technical User
Nov 28, 2005
43
US
Front Page 2002

I have been trying to find a post that I think was on a long time ago but I will repost and ask this question.....I have a very short welcome audio that plays in the background as a hidden plug-in. I would like to add code so that it only plays on first entry to the page not each time someone returns to that page...I believe I saw a post which said how to do this. Any suggestions or references?

Also, I have hover buttons which I am trying to assign onclick wav files. Some of the button wav files work and some do not. Is there a trick to this? I read something about using au files instead of wav files but the wav files SEEM to work on other buttons.

Any help? Thank you very much!
 
Code:
//cookie for entrancescript
function onLoadFunction(){
 if(!getCookie("P5day"))

play();// this is where you put your audio function

   SetCookie("P5day","yes");
} 

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 getCookieVal (j);
     }

     i = document.cookie.indexOf(" ", i) + 1; 
     if (i == 0) break; 
     
  }
  return null;
}

function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie(name, value, expires, path, domain, secure) {
var midnight = new Date()
midnight.setHours(23,59,59,999)
expires = midnight

  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
//end cookie for entrancescript
[COLOR=red]<body onload = "onLoadFunction()">[/color]

Glen
 
WOW THank you VERY much! I'm certain that my visitors will thank you as well. I like the effect of a very brief intro audio but not every time they visit the page of course. I am not sure how to but could someone please mark this so that people will see this is a very GOOD post. Thank you again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top