如何“点击”函数控制两个图像状态
我的网站中有一个音乐播放器,代码如下:
<!-- player -->
<div id="player">
<div class="playerIcon"><img src="../img/musicIcon.gif" alt="" width="21" height="19" border="0"></div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="30" height="30" id="player1">
<PARAM NAME=movie VALUE="audioplay.swf?playerid=1">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=wmode VALUE="transparent">
<PARAM NAME="allowScriptAccess" value="always" />
<embed wmode="transparent" src="audioplay.swf?playerid=1" quality=high width="30" height="30" name="player1" allowScriptAccess="always"
align="" TYPE="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
<script language="javascript">
function getPlayer(movieName){
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];}
else {
return document[movieName];
}
}
function play1() {
getPlayer('player1').playMusic();
}
function stop1(){
getPlayer('player1').stopMusic();
}
</script>
</div>
<!-- end player -->
这里,player1 有自己的图标,并且在单击暂停音乐时也有开关状态。当我单击播放器图标时,我还想将动画 musicIcon.gif img 更改为非动画图像。我该怎么做? 感谢和问候
I have a music player in my site, here is the code:
<!-- player -->
<div id="player">
<div class="playerIcon"><img src="../img/musicIcon.gif" alt="" width="21" height="19" border="0"></div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="30" height="30" id="player1">
<PARAM NAME=movie VALUE="audioplay.swf?playerid=1">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=wmode VALUE="transparent">
<PARAM NAME="allowScriptAccess" value="always" />
<embed wmode="transparent" src="audioplay.swf?playerid=1" quality=high width="30" height="30" name="player1" allowScriptAccess="always"
align="" TYPE="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
<script language="javascript">
function getPlayer(movieName){
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];}
else {
return document[movieName];
}
}
function play1() {
getPlayer('player1').playMusic();
}
function stop1(){
getPlayer('player1').stopMusic();
}
</script>
</div>
<!-- end player -->
Here, player1 has its own icon and also on-off state when click to pause music. I'd like to change also animated musicIcon.gif img to non-animated one when i click player icon. How can i do this?
Thanks and regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 object 元素上放置一个点击侦听器吗?调用时,它应该查看电影的状态,如果已停止,请将
替换为静态图像。如果它正在运行,请使用动画的。
您也可以在页面中已有这两个图像,只需在 'none' 和 ''(空字符串)之间切换它们的 .style.display 属性即可)。
Can you put a click listener on the object element? When called, it should look at the state of the movie and if it's stopped, replace
<img src="..." ...>
with the static image. If it's running, use the animated one.You could also have both images in the page already and just toggle their .style.display property between 'none' and '' (empty string).