简体   繁体   English

Safari(Windows)中的确认或警告框需要双击 - 为什么?

[英]confirm or alert boxes in safari(Windows) needs double click-why?

I am doing a very simple example in JavaScript like displaying an alert box on click event of an HTML button in SAFARI.The problem is, it requires double click to disapear from the screen.我在 JavaScript 中做了一个非常简单的示例,例如在 SAFARI 中的 HTML 按钮的单击事件上显示警报框。问题是,它需要双击才能从屏幕上消失。

Anyone have any idea about this?有人对此有任何想法吗?
By the way I am using safari(5.0.5) on windows XP platform.顺便说一句,我在 windows XP 平台上使用 safari(5.0.5)。

Here is the code:这是代码:

<HTML> 
   <HEAD> 
     <TITLE>Using the ondblclick Event</TITLE> 
     <script type="text/javascript"> 
        function display() { 
          alert('this is BUTTON CLICK alert'); 
        } 

        function display2() { 
          alert('this is a ONLOAD alert'); 
        }
     </script> 
   </HEAD> 

   <BODY onLoad="display2();"> 
     <input type="button" id="b" value="Click Here!" onClick="display();" /> 
   </BODY> 
</HTML>

By the way I think this problem is not occuring on MAC OS as I had concerned with one of my friend.this problem is occuring on windows platform.顺便说一句,我认为这个问题不会发生在 MAC OS 上,因为我担心我的一位朋友。这个问题发生在 windows 平台上。

Thanks in advance!提前致谢!

This seems to be a Safari on Windows bug, not an issue with your code.这似乎是 Windows 错误上的 Safari,而不是您的代码问题。 Clicking the alert box in Safari / Windows will initially actually click through it onto your page.单击 Safari / Windows 中的警告框最初实际上会单击它进入您的页面。

This is a larger issue when the alert pops up over something causing the alert (ie: your button in this case), in which case clicking the "Ok" button generates another alert (since the click actually hit the button again).当警报弹出导致警报的某些东西(即:在这种情况下为您的按钮)时,这是一个更大的问题,在这种情况下,单击“确定”按钮会生成另一个警报(因为单击实际上再次点击了该按钮)。

I haven't tried it yet, but a suggestion to get around this is to use a jQuery dialogue instead.我还没有尝试过,但解决这个问题的建议是使用 jQuery 对话代替。 See jquery: a safari bug?请参阅jquery:safari 错误? for reference.以供参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM