I'm having a weird error with Internet Explorer (Currently version 8, but had the same issue with 7). When clicking a link such as:
<a href="#">Hello</a>
the page is completely reloaded no matter what.
However a link such as this:
<a>Hello</a>
will work correctly and not reload the entire page.
Is there some sort of setting in IE that can cause this functionality to change?
Info: I have already set security settings to low, and have disabled all addons plus the 'Enable third party addons' option.
Any suggestions are helpful, thanks.
EDIT: Here is what I'm testing
<a href="#" id="btnAddStuff" runat="server" onclick="displayAddStuff();" style="cursor:pointer;">
<asp:Literal ID="litAddStuff" runat="server" Text="Add Stuff" /></a>
EDIT #2: I have tested this with multiple versions of IE. With a clean install it works correctly. However testing on a random user's machine with different settings causes the issue.
EDIT #3: Thanks for the replies on how to make this code better. While I appreciate that, my question is if anyone knows if there are configurable settings in Internet Explorer that can cause the browser to run the above code differently?
If you know a little javasript and or jQuery, you could do this:
$("a[rel='prevDefault']").on('click', function(event){
if($(this).attr("href").indexOf("#") > -1){
event.preventDefault();
}
});
or:
var anchorArray = document.getElementsByTagName("a"), I;
for(I=0;I<anchorArray.length;I++){
anchorArray[I].click = function(event){
if(anchorArray[I].href.indexOf("#") > -1){
event.preventDefault();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With