Trending News
jQuery image map onclick it ??
我想請問各位高手有關jQuery 裏面,如果要用番舊的HTML 的image map 之後onlcik 指向一個URL or onclick 後那sound icon可以發聲play sound of WAV????
其實只是onclick 一個icon 之後load 一個發音,只係咁,所以應該唔使用if .. else, 但我試過jQuery code 不可只寫image map 咁簡單,要有其他code embed.
e.g.
我在IE的browser上可以play sound , but in iphone it doesn't work who can help me?
1 Answer
- 8 years agoFavorite Answer
onclick之後那sound icon? 即係本身已經一個sound icon. click左唔同image再click個sound icon 會load 唔同的聲?
定係你想咁?
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
function image_map_click(key) {
if (key == 'knowledge') {
playSound('http://www6.flash8.net/file/sound/fx/dw/dw001.mp3'...
//window.location = 'http://hk.knowledge.yahoo.com/question/question?qi...
}
else if (key == 'yahoo') {
playSound('http://www6.flash8.net/file/sound/fx/dw/dw026.mp3'...
//window.location = 'http://hk.yahoo.com'/
}
}
function playSound(soundUrl) {
if ($('#soundPlayer').length > 0) {
$('#soundPlayer').remove();
}
var soundPlayer = $('<embed/>').attr('id','soundPlayer');
soundPlayer.attr('width','0px').attr('height','0px');
soundPlayer.attr('src',soundUrl);
soundPlayer.attr('autoplay','true');
$('body').append(soundPlayer);
soundPlayer.hide();
}
</script>
</head>
<body>
<img src="http://l.yimg.com/qo/akp_logo/akp_hk_20120920.gif%... width="205" height="41" alt="" usemap="#image_map" border="0" />
<map name="image_map">
<area shape="rect" coords="0,0,136,41" alt="雅虎" href="javascript:image_map_click('yahoo');">
<area shape="rect" coords="150,0,205,30" alt="知識" href="javascript:image_map_click('knowledge');">
</map>
</body>
</html>