I have an ASP button that when clicked brings up a window.confirm
. This window.confirm
disappears without user interaction. However, if I keep clicking the ASP button, after about the 4th or 5th click the window.confirm
box will work as expected.
A couple of things that I also noticed, after hours of working on it, if I remove the Text
property from the ASP button, the window.confirm
works as it should.
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');"/>
I've just faced the same issue. As investigating the problem I've found out that the code itself is ok, but after puting it in the context of the website - starts failing as described above. The problem seems to be the facebook tracking code called through GTM. If I remove the whole Google Tag manager code from the header - everything just works fine
Although it's not the sollution yet, so I'll need some deeper GTM investigation to prevent this behaviour. But this also might help you...
This sounds like a clue because I did notice something about "Waiting to Load Facebook.. yadayada" on the bottom of the page. let me check it out
Do you happen to have the actual line of code you deleted?
Yep!!! good ol' Google Analytics. I went through and commented out all the code that involved Google Analytics and it worked. Like you said, it is not the final solution, but it is good to know that has nothing to do with our direct code. I am going to accept your answer and see if I can find a workaround for this issue. Thanks!!!
@DJBurb where you able to find a solution which does not involve removing GA / GTM ?
@DJBurb check if they other available computers using chrome has any ad-blocking enabled. For myself on my pc: 1) With ad-blocking enable confirm() and alert() works 100% as fbevents and other scripts via GTM is blocked. 2) Same chrome browser with adblock ( ublock ) disabled, then confirm and alert() does NOT work. In our situation we cannot remove GTM, so for internal staff we have enabled ad-blocking. Looking for solution for external clients to that portal where GTM is a must.