I’m using asp.net to add add a client side onclick event to a span tag in a ListView:
<span id="mySpan" onclick="<%# Request.Cookies["myCookie"] != null ? "MyFunction1(" + Eval("MyVal1") + ");" : "MyFunction2(" + Eval("MyVal2") + ");" %>"
Every aspect of what I’m doing always works perfectly in Chrome and FF 100% of the time. In IE (v8 and v9), it always adds the correct javascript function and all of the code looks perfect – the rendered span code in IE looks identical to how it looks in Chrome and FF. However, when monitoring traffic with Fiddler, several random IE spans don’t trigger the javascript function at all. Some do. There is no difference in the code between ones that work and ones that do not work. The ones that don’t work in IE work fine in Chrome and FF. I am also able to confirm the javascript function isn’t being fired by using means other than Fiddler, so Fiddler isn’t giving me false readings.
Is there something I’m doing in my asp code to add the function that may be screwing this up in IE?
I’m guessing this is a problem with the javascript functions you’re running. Try putting
alertmessages at various points inFunction1‘s execution to figure out where it is breaking. You probably have javascript code that isn’t cross-browser compatible, but which only gets hit for certain elements.