gpt4 book ai didi

javascript - 有条件地包含浏览器脚本

转载 作者:行者123 更新时间:2023-11-30 16:53:12 25 4
gpt4 key购买 nike

我有这样的脚本代码:

setTimeout(function () {
$('.grayscale .inactive img').each(function () {
$(this).wrap('<div style="display:inline-block;width:' + this.width + 'px;height:' + this.height + 'px;">').clone().addClass('gotcolors').css({
'position': 'absolute',
'opacity': 0
}).insertBefore(this);
this.src = grayscale(this.src);
}).animate({opacity: 1}, 500);

$(".grayscale li").hover(function () {
$(this).find('.gotcolors').stop().animate({opacity: 1}, 200);
}, function () {
$(this).find('.gotcolors').stop().animate({opacity: 0}, 500);
});
}, 1);`

我在 Mozilla Firefox 中需要它,在 Chrome 中我遇到了这个 grayscale(this.src) 的错误。我怎样才能只为 Mozilla Firefox 添加这个脚本?

最佳答案

您可以在不使用任何库的情况下实现这一点。方法如下:

if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1)
{
//Your code
}

关于javascript - 有条件地包含浏览器脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30182750/

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