gpt4 book ai didi

javascript - IE中的jQuery onClick()声音效果和重定向

转载 作者:行者123 更新时间:2023-12-03 02:28:46 26 4
gpt4 key购买 nike

因此,在我和老板的建议下,一个客户坚持认为,在链接实际将用户带到新页面之前,当他们单击它们时,希望在其网站主导航上的所有链接上都具有“boing”的音效。

为此,在将用户发送到新页面之前,单击链接时,我使用jQuery将embed标记附加到主体。这是我正在使用的jQuery:

<script type="text/javascript">
(function($) {
$(document).ready(function() {
$("#menu_container a").click(function(e) {
e.preventDefault();
var url = $(this).attr('href');

$('body').append('<embed src="/media/sounds/boing_spring.mp3" autostart="true" width="1" height="1" id="LegacySound" enablejavascript="true">');

setTimeout(function() {
window.location = url;
}, 500);

setTimeout();
});
});
})(jQuery)
</script>

因此,这似乎可以在OSX / Ubuntu和Windows的Safari / Chrome / FF / Opera中正常运行。

但是,当谈到Internet Explorer时,在装有IE8的WinXP机器上就可以正常工作,但声音在运行IE9的老板Win7机器上却不起作用。那么,这可能是什么原因呢?是jsut IE是IE,还是我搞砸了?

最佳答案

通过添加另一行(如一个蜂鸣声)来解决,但改为链接到wma声音

$('body').append('<embed src="/media/sounds/boing_spring.mp3" autostart="true" width="1" height="1" id="LegacySound" enablejavascript="true">');

关于javascript - IE中的jQuery onClick()声音效果和重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11969900/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com