Wicket
  1. Wicket
  2. WICKET-5119

PopupSettings IE8 - dosen't work second time a link is clicked.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.4.0
    • Fix Version/s: 6.8.0, 1.5.11
    • Component/s: wicket
    • Labels:
      None

      Description

      Hi,

      The popup functionality causes a script error in IE8, if the popup window is already open. As a result the link's default behaviour is executed instead - as ' return false; ' never is reached.

      Class: org.apache.wicket.markup.html.link.PopupSettings

      The problem exists in line: 188 // if(w.blur) w.focus();

      In IE8 blur and focus isen't defined - secound time a popup link is called and therefore the logic breaks.

      //An alternative: (test if w.blur is defined)
      script.append("'); if( jQuery.isFunction( w.blur ) && w.blur )

      { w.focus(); }

      ").append(" return false;");

      Br,
      Uffe.

      1. quickstart-onissue.zip
        256 kB
        Uffe Heerfordt
      2. pages-in-popup.tgz
        254 kB
        Martin Grigorov

        Activity

        Hide
        Martin Grigorov added a comment -

        I cannot reproduce the problem.
        I don't have real IE 7/8 around so I use IE9 in IE 7/8 mode.
        At http://www.wicket-library.com/wicket-examples-6.0.x/linkomatic/home I click on the link with text "Click this link for a popup" and then I click second time on the same link without closing the popup.
        Are the steps correct ?

        Could it be something related to your installation of IE 8 ? Can you try from a different machine too ? Also please try with different DOCTYPE, preferably HTML5.

        Show
        Martin Grigorov added a comment - I cannot reproduce the problem. I don't have real IE 7/8 around so I use IE9 in IE 7/8 mode. At http://www.wicket-library.com/wicket-examples-6.0.x/linkomatic/home I click on the link with text "Click this link for a popup" and then I click second time on the same link without closing the popup. Are the steps correct ? Could it be something related to your installation of IE 8 ? Can you try from a different machine too ? Also please try with different DOCTYPE, preferably HTML5.
        Hide
        Joel Hill added a comment -

        I have been running into this issue recently as well. In my case, the link is bringing up a PDF document. Perhaps the fact that it is not an HTML document, some of the object data is being discarded so that repeated calls to window.open, using the same window name, are failing.

        If I override PopupSettings.getPopupJavaScript() with the following, I get an error message of "Error: Member not found.":

        return "try

        {" + super.getPopupJavaScript() + "}

        catch (err)

        {alert(err);}

        ";

        I have found this to be a very crude workaround, which also overrides PopupSettings.getPopupJavaScript():

        return "var win = window.open('about:blank', '" + WINDOW_NAME + "','width="+ WIDTH +",height=" + HEIGHT + "'); win.close(); " + super.getPopupJavaScript();

        The big downside is the FIRST time you click the link, a temporary window pops up and quickly closes before your actual link content appears. That is the main reason I included width and height above, so the window mostly appears similar to the final popup. Also WINDOW_NAME must match whatever window name you're passing to PopupSettings. The following link talks about this issue, and also links to another page where I got this crude workaround:

        http://stackoverflow.com/questions/987572/opening-a-popup-in-ie-member-not-found

        The solution provided at stackoverflow may be a better option, but could not be accomplished with a simple override of getPopupJavaScript(). The strange thing is this issue did not occur when I was still using wicket 1.4. I know I had to make significant code changes when I converted to 1.5, but I have yet to see how any of those changes would suddenly cause this bug to occur. I am still investigating this issue on my own, now that I am narrowing in on the cause.

        Show
        Joel Hill added a comment - I have been running into this issue recently as well. In my case, the link is bringing up a PDF document. Perhaps the fact that it is not an HTML document, some of the object data is being discarded so that repeated calls to window.open, using the same window name, are failing. If I override PopupSettings.getPopupJavaScript() with the following, I get an error message of "Error: Member not found.": return "try {" + super.getPopupJavaScript() + "} catch (err) {alert(err);} "; I have found this to be a very crude workaround, which also overrides PopupSettings.getPopupJavaScript(): return "var win = window.open('about:blank', '" + WINDOW_NAME + "','width="+ WIDTH +",height=" + HEIGHT + "'); win.close(); " + super.getPopupJavaScript(); The big downside is the FIRST time you click the link, a temporary window pops up and quickly closes before your actual link content appears. That is the main reason I included width and height above, so the window mostly appears similar to the final popup. Also WINDOW_NAME must match whatever window name you're passing to PopupSettings. The following link talks about this issue, and also links to another page where I got this crude workaround: http://stackoverflow.com/questions/987572/opening-a-popup-in-ie-member-not-found The solution provided at stackoverflow may be a better option, but could not be accomplished with a simple override of getPopupJavaScript(). The strange thing is this issue did not occur when I was still using wicket 1.4. I know I had to make significant code changes when I converted to 1.5, but I have yet to see how any of those changes would suddenly cause this bug to occur. I am still investigating this issue on my own, now that I am narrowing in on the cause.
        Hide
        Joel Hill added a comment -

        Also, this bug appears in IE10, so I would assume IE9 is not immune to it.

        Show
        Joel Hill added a comment - Also, this bug appears in IE10, so I would assume IE9 is not immune to it.
        Hide
        Martin Grigorov added a comment -

        Hi Joel,

        Can you reproduce the problem at http://www.wicket-library.com/wicket-examples-6.0.x/linkomatic/home ?
        What steps I should follow to be able to reproduce it ?

        Show
        Martin Grigorov added a comment - Hi Joel, Can you reproduce the problem at http://www.wicket-library.com/wicket-examples-6.0.x/linkomatic/home ? What steps I should follow to be able to reproduce it ?
        Hide
        Joel Hill added a comment -

        I cannot reproduce it at linkomatic, but there also isn't a popup that brings up a PDF file. I don't know what the original reporter's link is bringing up, but having a PDF popup seems to be integral to my issue (I have HTML popups that work fine). For some reason the focus() method is not defined for the javascript window object in IE. When the call to focus fails, since the URL is defined in the HREF attribute, IE navigates the main window to the PDF document. However, since the error occurs after the call to window.open, the PDF document loads in existing popup as well.

        If I had time, I would try and add a PDF popup to the linkomatic example. Unfortunately I have to move on to a different task for now. I don't know if or when I'll be able to swing back around to this problem and see if I can recreate it by modifying linkomatic.

        For now I have to drop in a partial workaround in our app and move on.

        Show
        Joel Hill added a comment - I cannot reproduce it at linkomatic, but there also isn't a popup that brings up a PDF file. I don't know what the original reporter's link is bringing up, but having a PDF popup seems to be integral to my issue (I have HTML popups that work fine). For some reason the focus() method is not defined for the javascript window object in IE. When the call to focus fails, since the URL is defined in the HREF attribute, IE navigates the main window to the PDF document. However, since the error occurs after the call to window.open, the PDF document loads in existing popup as well. If I had time, I would try and add a PDF popup to the linkomatic example. Unfortunately I have to move on to a different task for now. I don't know if or when I'll be able to swing back around to this problem and see if I can recreate it by modifying linkomatic. For now I have to drop in a partial workaround in our app and move on.
        Hide
        Martin Grigorov added a comment -

        Please attach a quickstart demonstrating the problem and we will fix it for the next version of Wicket.

        Show
        Martin Grigorov added a comment - Please attach a quickstart demonstrating the problem and we will fix it for the next version of Wicket.
        Hide
        Uffe Heerfordt added a comment -

        Quickstart project that shows the problem in IE.

        Show
        Uffe Heerfordt added a comment - Quickstart project that shows the problem in IE.
        Hide
        Uffe Heerfordt added a comment -

        Hi,

        My first report was maybe a bit vague so I have now added a Quickstart project that can recreate the issue. The issue is only visible in Internet Explorer and I have been able to reproduce it in IE8,IE9 and IE10.

        Steps to reproduce the problem:

        1. Start the attached quickstart project
        2. Click one first link on the default page. (popup shows nicely and has the focus)
        3. Now click on secound link without closing the popupwindow. (script error occurs and content is shown in main window)

        Script Error: 'Member not found' is thrown when focus() is called on the popup window.

        Br,
        Uffe

        Show
        Uffe Heerfordt added a comment - Hi, My first report was maybe a bit vague so I have now added a Quickstart project that can recreate the issue. The issue is only visible in Internet Explorer and I have been able to reproduce it in IE8,IE9 and IE10. Steps to reproduce the problem: 1. Start the attached quickstart project 2. Click one first link on the default page. (popup shows nicely and has the focus) 3. Now click on secound link without closing the popupwindow. (script error occurs and content is shown in main window) Script Error: 'Member not found' is thrown when focus() is called on the popup window. Br, Uffe
        Hide
        Martin Grigorov added a comment -

        Hi Uffe,

        I was not able to reproduce the problem with your application because my IE9 was downloading the .pdf instead of showing it in a popup window.

        Can you try with "pages-in-popup.tgz" ?
        It works fine for me. IE9 v.9.0.8 on Windows 7

        Show
        Martin Grigorov added a comment - Hi Uffe, I was not able to reproduce the problem with your application because my IE9 was downloading the .pdf instead of showing it in a popup window. Can you try with "pages-in-popup.tgz" ? It works fine for me. IE9 v.9.0.8 on Windows 7
        Hide
        Martin Grigorov added a comment -

        I'm able to reproduce the problem now.

        Show
        Martin Grigorov added a comment - I'm able to reproduce the problem now.
        Hide
        Martin Grigorov added a comment -

        The suggested solution:

        script.append("'); if( jQuery.isFunction( w.blur ) && w.blur )

        { w.focus(); }

        ").append(" return false;");

        doesn't work for me. It fails with an error in the dev tools' console.

        According to http://msdn.microsoft.com/en-us/library/ms536425%28VS.85%29.aspx :

        Windows Internet Explorer 8 and later. The focus method no longer brings child windows (such as those created with the open method) to the foreground. Child windows now request focus from the user, usually by flashing the title bar. To directly bring the window to the foreground, add script to the child window that calls the focus method of its window object.

        So it seems there is no way to bring to the foreground a popup with a PDF content. If the content is HTML then you should use OnDomReadyHeaderItem.forScript("self.focus()").

        Removing the problematic "if (w.blur) w.focus()" doesn't break the current behavior in Chrome browser, but breaks it in Firefox, i.e. the popup window is not focused after loading the new content - as in IE.
        At the moment I don't have a better solution.

        Show
        Martin Grigorov added a comment - The suggested solution: script.append("'); if( jQuery.isFunction( w.blur ) && w.blur ) { w.focus(); } ").append(" return false;"); doesn't work for me. It fails with an error in the dev tools' console. According to http://msdn.microsoft.com/en-us/library/ms536425%28VS.85%29.aspx : Windows Internet Explorer 8 and later. The focus method no longer brings child windows (such as those created with the open method) to the foreground. Child windows now request focus from the user, usually by flashing the title bar. To directly bring the window to the foreground, add script to the child window that calls the focus method of its window object. So it seems there is no way to bring to the foreground a popup with a PDF content. If the content is HTML then you should use OnDomReadyHeaderItem.forScript("self.focus()"). Removing the problematic "if (w.blur) w.focus()" doesn't break the current behavior in Chrome browser, but breaks it in Firefox, i.e. the popup window is not focused after loading the new content - as in IE. At the moment I don't have a better solution.
        Hide
        Uffe Heerfordt added a comment -

        Hi,

        The first proposed solution wasen't very thought through by me - I have afterwards attempted different solutions like doing an explict close() on the popup... attempting to to store the window in a global variable to reuse it... and doing a document write... to get IE to unload the plugin. However none of the attempts fully worked, I guess the two options are to either remove the focus logic or to supress the exception by adding try{}catch(ignore){} around the statement.. When testing in IE without the logic, it seems to auto focus the popup automaticly. There dosen't seem to be a perfect fix for this atm, only a workaround.

        Br,
        Uffe

        Show
        Uffe Heerfordt added a comment - Hi, The first proposed solution wasen't very thought through by me - I have afterwards attempted different solutions like doing an explict close() on the popup... attempting to to store the window in a global variable to reuse it... and doing a document write... to get IE to unload the plugin. However none of the attempts fully worked, I guess the two options are to either remove the focus logic or to supress the exception by adding try{}catch(ignore){} around the statement.. When testing in IE without the logic, it seems to auto focus the popup automaticly. There dosen't seem to be a perfect fix for this atm, only a workaround. Br, Uffe
        Hide
        Martin Grigorov added a comment -

        I've tried many things and none of them made IE9 focusing the popup when the second link is clicked.
        So I've try/catched the focusing code as you suggested.

        Show
        Martin Grigorov added a comment - I've tried many things and none of them made IE9 focusing the popup when the second link is clicked. So I've try/catched the focusing code as you suggested.

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Uffe Heerfordt
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.25h
              0.25h
              Remaining:
              Remaining Estimate - 0.25h
              0.25h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development