Jquery 函数的作用是:在Microsoft Edge上从1开始计数,而不是从0开始计数

Jquery 函数的作用是:在Microsoft Edge上从1开始计数,而不是从0开始计数,jquery,wordpress,slice,microsoft-edge,Jquery,Wordpress,Slice,Microsoft Edge,今天我在我创建的网站上发现了一些奇怪的问题。 我正在使用slice()函数根据一些属性获取链接 它在Chrome/Firefox/Opera/Safari上运行得非常完美,但出于某种原因,它在Microsoft Edge上似乎遇到了困难 在现代浏览器上,sliced()链接显示如下: http://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/img/docisk-dwustron

今天我在我创建的网站上发现了一些奇怪的问题。 我正在使用
slice()
函数根据一些属性获取链接

它在Chrome/Firefox/Opera/Safari上运行得非常完美,但出于某种原因,它在Microsoft Edge上似乎遇到了困难

在现代浏览器上,
sliced()
链接显示如下:

http://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/img/docisk-dwustronny.jpg

在Microsoft Edge上使用相同的脚本时,它会变成:

ttp://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/img/docisk-dwustronny.jp

意思是开头和结尾都有一个字母被剪掉了

有没有人也经历过这样的问题?有什么解决办法吗

编辑:

jQuery:

 $(".zoom").click(function() {
    $bgimg = $(this).parent().parent().parent().css("background-image");
    $bgimgcut = $bgimg.slice(5,-2);
    $img = "<img src='" + $bgimgcut + "' width='100%'/>";
    $(".popup-image").html($img);
    $(".popup").fadeIn();
  });
$(“.zoom”)。单击(函数(){
$bgimg=$(this.parent().parent().parent().css(“背景图像”);
$bgimgcut=$bgimg.slice(5,-2);
$img=“”;
$(“.popup image”).html($img);
$(“.popup”).fadeIn();
});

如果让我猜的话,除了Edge之外的所有东西都回来了

url(“http://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/img/docisk-dwustronny.jpg")
Edge返回的值相同,不带引号

url(http://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/img/docisk-dwustronny.jpg)
你可以跟我确认一下

console.log('$bgimg', $bgimg)

因此,听起来您真正的问题是如何从CSS
URL(…)
值中提取图像URL,无论是否包含引号字符

使用正则表达式

$bgimgcut = $bgimg.match(/url\("?(.*?)"?\)/)[1]
const rx=/url\(?(.*?)?\)/
常量字符串=[
'url('http://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/img/docisk-dwustronny.jpg")',
'网址(http://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/img/docisk-dwustronny.jpg)'
]
strings.forEach(str=>{
console.info('url',str.match(rx)[1])

})
你的代码在哪里?@Phil jQuery code added,如果还需要什么,请告诉我返回一个字符串,以便你实际使用,而不是jQuery
.slice()
。首先调试
$bgimg
~
console.log('$bgimg',bgimg)