2013-10-16 28 views
1

http://localboyoutfitters.com的onmouseover不会在Safari工作

工作正常,在Chrome /火狐/ IE浏览器,但只有第三悬停图像在Safari工作。

这是我的代码为其中一个图像..(我的选项卡按钮被打破,所以很抱歉格式不对) (我有一个支架在下面的href但我的键盘限制bc我不得不把它拿走)

<a href="http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMnew.png"> 
<img src="http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMnew.png" alt="LBO_topoffer_SMnew" onmouseover="this.src='http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMhover.png'" onmouseout="this.src='http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMnew.png'" width="300" height="200" class="alignnone size-full wp-image-205" /> 
</a> 

这是放置在Wordpress部件区域。

如果有人有任何解决方案,将不胜感激!

+0

尝试OnMouseEnter在/ OnMouseLeave在 – Xaver

+0

至少在这里,它工作正常的Safari。哪个操作系统上的Safari版本? –

回答

-1

更好的办法是使用了mouseenter和鼠标离开:

<a href="http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMnew.png"> 
<img src="http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMnew.png" alt="LBO_topoffer_SMnew" onmouseenter="this.src='http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMhover.png'" onmouseleave="this.src='http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMnew.png'" width="300" height="200" class="alignnone size-full wp-image-205" /> 
</a> 
+0

'mouseenter'和'mouseleave'是MS发明,只有IE支持很长一段时间。虽然他们现在是(afaik)现在是DOM3 Events规范的一部分,但浏览器支持不是最好的(Chrome 30+,FF 10+ Opera 11.10+)。而且Safari甚至不支持'mouseenter' /'mouseleave'与它的当前版本,所以这显然不能解决Safari问题。 –

-1

你可以做到这一点很容易在jQuery中,一些JavaScript代码不会与您可以检查jQuery的其他浏览器,你必须创建一个功能。你必须添加以下代码:

<script> 
     function mouse(){ 
      $(document).ready(function(){ 
       window.location("anywebsite"); 
      }); 
     } 
</script> 




<img src="http://localboyoutfitters.com/wp-content/uploads/2013/10/LBO_topoffer_SMnew.png" alt="LBO_topoffer_SMnew" onmouseenter="mouse();" width="300" height="200" class="alignnone size-full wp-image-205" /> 
+0

你的回答没有多大意义。在问题图像交换,但你的例子看起来像你想改变的URL。进一步改变'window.location'不需要放在一个'ready'回调文件中。 Safari也不支持'mouseenter'。如果你建议使用jquery,也可以使用'.on'显示如何使用jquery附加事件。 –