ICEfaces
  1. ICEfaces
  2. ICE-3470

Use of javascript: protocol in href attribute of an anchor tag causes IE to stop working

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.7.1
    • Fix Version/s: 1.7.2
    • Component/s: Bridge
    • Labels:
      None
    • Environment:
      IE
    • Support Case References:
      Show
      https://www.icesoft.ca:4443/supportilla/show_bug.cgi?id=4552
    • Workaround Exists:
      Yes
    • Workaround Description:
      Hide
      Use the onclick handler rather than the href attribute. Instead of:

          <a href="javascript:stay();">Stay (via javascript: from href)</a> (this one triggers onbeforeunload with IE)<br/>

      Use:

          <a onclick="stay();" href="#">Stay (via onclick)</a> <br/>
      Show
      Use the onclick handler rather than the href attribute. Instead of:     <a href="javascript:stay();">Stay (via javascript: from href)</a> (this one triggers onbeforeunload with IE)<br/> Use:     <a onclick="stay();" href="#">Stay (via onclick)</a> <br/>

      Description

      if you use the javascript: protocol in the href attribute of an anchor, it causes an ICEfaces page running in IE to stop working. If you move the code into the onclick of the anchor, it seems to be okay - this is the suggested workaround. Here's a snippet from the test case to illustrate:

      This is bad:

          <a href="javascript:stay();">Stay (via javascript: from href)</a> (this one triggers onbeforeunload with IE)<br/>

      This is okay (of course you don't need to use the javascript: protocol if you use the onclick handler):

          <a onclick="stay();" href="#">Stay (via onclick)</a> <br/>

      If your actions in the script triggered event actually causes you to leave the page, the event fires twice in IE:

          <a href="javascript:leave();">Leave (via javascript: from href)</a><br/>

      The problem is that use of the javascript: protocol in IE triggers the beforeunload event to fire (but not the unload event). The ICEfaces JavaScript bridge relies on the event to do some cleanup operations. Because the bridge gets cleaned up, further action on the page will not work.
      1. js.html
        2 kB
        Deryk Sinotte

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Deryk Sinotte
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: