Javascript 只有在SVG上的Chrome中加载页面后,鼠标才能进入工作状态
我有一个带有SVG的web应用程序(在Ilustrator上) 当您点击“Complejo A”时,您可以在本地(A13、A14等)上进行鼠标悬停,并将其切换为蓝色。它在Firefox和Iexplorer上运行得很好,但在Chrome上大部分时间都失败了 其功能是:Javascript 只有在SVG上的Chrome中加载页面后,鼠标才能进入工作状态,javascript,jquery,svg,Javascript,Jquery,Svg,我有一个带有SVG的web应用程序(在Ilustrator上) 当您点击“Complejo A”时,您可以在本地(A13、A14等)上进行鼠标悬停,并将其切换为蓝色。它在Firefox和Iexplorer上运行得很好,但在Chrome上大部分时间都失败了 其功能是: function showLocal(id, event) { var a; a=document.getElementById(id); var svgDoc = (a.contentDocument); var
function showLocal(id, event) {
var a;
a=document.getElementById(id);
var svgDoc = (a.contentDocument);
var color_original;
var fondo_original;
$('#locales g', svgDoc).on('mouseenter', function(e){ // <-------------
fondo_original=$(this).find('rect').css('fill');
color_original_text=$(this).find('text').css('fill');
color_original=$(this).find('tspan').css('fill');
fondo_original2=$(this).find('path').css('fill');
paintLocal($(this), fondo_activo, color_activo);
$(this).find('path').css('stroke', color_activo);
$(this).find('path').css('fill', fondo_activo);
moveWindow(id, e.clientX);
});
$('#locales g', svgDoc).on('mouseleave', function(e) {
$(this).find('rect').css('fill', fondo_original);
$(this).find('text').css('fill', color_original_text);
$(this).find('tspan').css('fill', color_original);
$(this).find('path').css('stroke', color_borde_libre);
$(this).find('path').css('fill', fondo_original2);
$('path', svgDoc).each(function(){
$(this).css('stroke', color_borde_libre);
$(this).find('path').css('fill', fondo_original2);
}
);
$('#p3').css('visibility', 'hidden');
});
不做断点,而在另一个和中,当工作时断点工作
我不知道现在该做什么。我在Chrome上看到网络控制台,一切正常,控制台中也有javascript错误。以下是我发现的有关此问题的信息,希望能有所帮助: 如果你想用鼠标指针代替鼠标指针。你应该知道Chrome和Safari还没有集成它 您可以改用鼠标悬停,但需要取消事件气泡 解决了 我在1秒后使用以下命令调用函数:
setTimeout(function(){ showLocals(event); }, 1000);
在Chrome、Firefox和Explorer中都能完美地工作
我不知道确切的原因。看起来像个Chrome bug
谢谢你的帮助,西莫
注:大量的时间损失。希望这对将来的任何人都有帮助 注意:SVG一开始是由Inkscape生成的,它在Chrome上始终正常工作。但它们在手机上不起作用。然后,为了解决这个问题,我们将SVG的软件导出到SVG basic,从而将其更改为Ilustrator。移动问题已经解决了,只需添加注释错误即可。格式保存在ilustrator:SVG 1.1中,但这意味着它有时会起作用,或者永远不会起作用?因为在移动到Ilustrator之前,该函数始终有效。这不是随机的。现在它是随机的。有时mouseenter可以工作。我做到了:$('#locales g',svgDoc)。在('mouseover',function(e){e.stopPropagation();…上,我得到了相同的结果。局部变量在某个时间重新引用时不会变成蓝色。还没有任何线索。
setTimeout(function(){ showLocals(event); }, 1000);