Wicket
  1. Wicket
  2. WICKET-1535

ExternalLink JavaScript not working in FF 3

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3.3
    • Fix Version/s: 1.3.5, 1.4-RC1
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      WinXP; Firefox 3.0 Beta 5

      Description

      If the link target isn't a proper anchor, the code generates a JS on-click handler, i.e.
      tag.put("onclick", "window.location.href='" + url + "';");
      which generates code such as
      onclick='window.location.href="http://news.bbc.co.uk";'

      The problem is that when this is used with a button /in a form/, while this works with IE & FF2, it appears that FF3 needs a 'return false;' at the end of the JS before it works, otherwise it just treats the button as a 'submit' action.

      So, is there any down-side to changing the above line in
      \org\apache\wicket\markup\html\link\ExternalLink.java
      to be
      tag.put("onclick", "window.location.href='" + url + "'; return false;"); ?

      /Gwyn

        Activity

        Hide
        Igor Vaynberg added a comment -

        there is nothing wrong with adding return false;

        Show
        Igor Vaynberg added a comment - there is nothing wrong with adding return false;
        Hide
        Gwyn Evans added a comment -

        Yes, but nothing definative - just some other reports of the same thing, I think.

        It's not major, as a workaround is to move the button outside a form, but it seems to me that in this usage, adding the "return false" and thus disabling the default action of the element /is/ the correct action. Unfortunately, I was too busy to follow up on this (as I found it during system testing), but I don't believe that it changes the behaviour of pre-FF3 browsers, just FF3.

        Show
        Gwyn Evans added a comment - Yes, but nothing definative - just some other reports of the same thing, I think. It's not major, as a workaround is to move the button outside a form, but it seems to me that in this usage, adding the "return false" and thus disabling the default action of the element /is/ the correct action. Unfortunately, I was too busy to follow up on this (as I found it during system testing), but I don't believe that it changes the behaviour of pre-FF3 browsers, just FF3.
        Hide
        Timo Rantalaiho added a comment -

        I'm not sure but a bit suspicious about the implications of adding "; return false;", so maybe another kind of fix should be looked for.

        Have you googled about why this behavior changed from Firefox 2 to 3?

        Show
        Timo Rantalaiho added a comment - I'm not sure but a bit suspicious about the implications of adding "; return false;", so maybe another kind of fix should be looked for. Have you googled about why this behavior changed from Firefox 2 to 3?
        Hide
        Martijn Dashorst added a comment -

        Moved to next milestone release.

        Show
        Martijn Dashorst added a comment - Moved to next milestone release.

          People

          • Assignee:
            Igor Vaynberg
            Reporter:
            Gwyn Evans
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development