return false; stopped working in IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iGuff
    New Member
    • Nov 2008
    • 3

    return false; stopped working in IE

    I have this sample page that I made, and it works fine in FF and Safari. But does not work in IE (all versions). I am currently using IE8, but it did not work on IE7 either. However, it used to work on this computer. Also, it is not an IE8 bug because it works in IE8 on other computers. So, I know this is not a coding error, but how do I fix my IE so it starts to understand "return false" again? This also affects a whole lot of sites out there using return false. Because it simply does not work on ANY site in my IE.

    It is very difficult testing new code (especially AJAX related things) when return false does not work and IE actually opens up all links that are clicked on even when its returned as false.

    I desperately want to solve this issue, however, I'd like to do anything but re-install Vista.

    [HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <body>
    <a id="lnkClick" href="http://google.com/" onclick="return false;">Click this</a>
    </body>
    </html>[/HTML]
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    JavaScript might be disabled. Check that it's enabled in IE - see enabling JavaScript.

    Comment

    • iGuff
      New Member
      • Nov 2008
      • 3

      #3
      Originally posted by acoder
      JavaScript might be disabled. Check that it's enabled in IE - see enabling JavaScript.
      JavaScript is enabled because all other JavaScript functions properly except that IE always follows links even if false is returned (like in this basic example). Plus, I've double checked that JavaScript is turned on. So basically IE runs the JS code associated with the onclick event, and then it follows the link. So, if you want buttons or links to do certain AJAX things, itd do them, but then it'd follow the link. What's the point of it loading things AJAX-style if in the end it follows the link anyways.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You could try the stopPropagation ()/preventDefault (standard) methods or the event.cancelBub ble property for IE. If that doesn't work, IE has a returnValue property for its global event object which you can set to false.

        Two more quick things. The above posted code does work normally, so there's something wrong in your IE. Try removing any addons/toolbars, etc. added to the browser. Finally, you can always use a button instead of links.

        Comment

        • iGuff
          New Member
          • Nov 2008
          • 3

          #5
          Originally posted by acoder
          You could try the stopPropagation ()/preventDefault (standard) methods or the event.cancelBub ble property for IE. If that doesn't work, IE has a returnValue property for its global event object which you can set to false.

          Two more quick things. The above posted code does work normally, so there's something wrong in your IE. Try removing any addons/toolbars, etc. added to the browser. Finally, you can always use a button instead of links.
          I dont have any toolbars installed, but there were some browser helper objects installed by a couple of applications, and when I disabled "McAfee Phishing Filter" and "scriptprox y" (both by McAfee), the return false started working again in IE. Yay. Thanks a bunch! I didnt even think of looking into these kinds of stuff since I have no toolbars/extensions installed. So if someone else has the same problem as I did, try disabling anything McAfee or anti-virus related for the browser.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Excellent! Glad you got it working.

            Comment

            Working...