温馨提示:本文翻译自stackoverflow.com,查看原文请点击:javascript - window.confirm disappears without interaction in Chrome

javascript - window.confirm消失,但在Chrome中没有交互

发布于 2020-03-27 11:03:45

我有一个ASP按钮,单击该按钮会弹出一个window.confirmwindow.confirm消失而无需用户交互。但是,如果我一直单击ASP按钮,则在大约第四或第五次单击后,该window.confirm框将按预期工作。

经过数小时的工作后,我还注意到了几件事,如果我Text从ASP按钮中删除该属性,则window.confirm可以正常工作。

This made me think, "Hmmmm... let me look at the <input> button that is behind the scenes of the ASP button, and I noticed that if I remove the value from the input the window.confirm works, but if I put a value in the input, the window.confirm stops working again.

Does anyone know what may cause this? Is there a work around to putting text in the button without using the Text property? I haven't tried innerHTML yet because I wanted to see if there is anything else I can do before I do that.

Btw, I tried using OnClientClick, instead of OnClick and I get the same results.

Here is the code that I have for the button:

<asp:Button ID="btSubmit" runat="server" Text ="Submit Email" OnClick="btSubmit_Click" OnClientClick="return confirm('Test');"/>

查看更多

查看更多

提问者
DJ Burb
被浏览
22
Gyürüs Máté 2019-07-04 13:40

我刚刚遇到了同样的问题。在调查问题时,我发现代码本身是可以的,但是将其放在网站的上下文中后,如上所述就开始失败。问题似乎是通过GTM调用的Facebook跟踪代码。如果我从标题中删除了整个Google跟踪代码管理器代码,则一切正常

尽管这还不是解决方案,但是我需要进行更深入的GTM调查,以防止此行为。但这也可以帮助您...

发布
问题

分享
好友

手机
浏览

扫码手机浏览