js脚本控制网页背景音乐,急,高分送出
在网页上放一个控制音乐播放的按钮<font size=-2>Music <A href="#" onclick="PlaySwitch();">ON/OFF</A></font>我需要的效果是当单击ON/OFF时,把状态写入cookie中,在以后的刷新时候,都会用cookie中的状态,这个情况在xp下完全正常,但是在vista下不行,vista需要单击2次才可以控制音乐播放和暂停,刷新之后又恢复原来的状态,各位高手,怎么办啊?
代码贴出来,帮我看一下,很急啊:
function setCookie(cookieName, cookieValue, cookiePath, cookieExpires)
{
cookieValue=escape(cookieValue);
if (cookieExpires=="")
{
var nowDate=new Date();
nowDate.setMonth(nowDate.getMonth() + 12);
cookieExpires=nowDate.toGMTString();
}
if (cookiePath != "")
{
cookiePath=";Path=" + cookiePath;
}
document.cookie=cookieName+ "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;
}
function getCookieValue(cookieName)
{
var cookieValue=document.cookie;
var cookieStartsAt=cookieValue.indexOf(" " + cookieName + "=");
if (cookieStartsAt == -1)
{
cookieStartsAt=cookieValue.indexOf(cookieName + "=");
}
if (cookieStartsAt == -1)
{
cookieValue=null;
}
else
{
cookieStartsAt=cookieValue.indexOf("=",cookieStartsAt) +1;
var cookieEndsAt=cookieValue.indexOf(";",cookieStartsAt);
if (cookieEndsAt == -1)
{
cookieEndsAt=cookieValue.length;
}
cookieValue = unescape(cookieValue.substring(cookieStartsAt,cookieEndsAt));
}
return cookieValue;
}
var thePlaySetting=getCookieValue("MusicOff");
function PlaySwitch()
{
var thePlaySetting=getCookieValue("MusicOff");
if(thePlaySetting==null)
{
setCookie("MusicOff","true","","");
MyPlayer.settings.mute = true;
MyPlayer.controls.stop();
}
else
{
setCookie("MusicOff","","","");
MyPlayer.settings.mute = false;
MyPlayer.controls.play();
}
}
Js脚本
<OBJECT ID="MyPlayer" height="0" width="0"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<PARAM NAME="uiMode" VALUE="invisible">
</OBJECT>
<SCRIPT LANGUAGE="JScript">
<!--
MyPlayer.settings.setMode("shuffle",true);
MyPlayer.settings.setMode("loop",true);
MyPlayer.URL = "SongListTotal.wax";
if (thePlaySetting!=null)
{
MyPlayer.settings.mute = true;
}
-->
</SCRIPT>
--------------------编程问答-------------------- 系统问题??。。。。。 --------------------编程问答-------------------- 系统问题 修改代码1 --------------------编程问答-------------------- 查看下IE6和IE7之间的区别问题。 --------------------编程问答-------------------- 要怎么修改啊?我在网上看了下,基本上都是这样写的,你有什么代码参考一下吗? --------------------编程问答-------------------- vista 有深度~~
UP~ --------------------编程问答-------------------- UP...................
补充:.NET技术 , ASP.NET