Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6980283

Opening a new browser window via javascript creates the window behind current

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 6u21
    • Fix Version/s: None
    • Component/s: deploy
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP SP3
      I have been able to replicate this using Internet Explorer, versions 6 and 7. When using Firefox 3 there is no issue

      ***NOTE***
      please see
      http://jpsescf.sfbay.sun.com/docs/vp/citi_esc_issue_01_jul_2010.html
      for history on this issue for CITI


      The following is copied from BUG
      6776124 Opening a new browser window via javascript creates the window behind current

      Ot has been recommended that CITI consider using showDocument as a
      solution to this issue, but they are unable to for the following reason
      ***
       I had provided you the code snippet we use to open a new window, here providing you some additional information which might help us.
      Below code we use to open a new window using java script in which we pass a set of parameters to the new window, the value of the parameter looks like:
      Argument 1 ( URL ) : https://cddfstx1.nam.nsroot.net/CasaSSL/ActuateViewer.html?/apweb/viewer/viewframeset.jsp?serverURL=http://cdrstxd21.nam.nsroot.net:8000&ACTUATE_EH_MODE=&locale=en_US&skinId=7b7c7d788c838b23&name=/AUDITARP/ROI0/710700.ROI
      Argument 2 ( Browser Name ) : ReportFrame710700
      Argument 3 ( Browser Params ) : menubar=no,location=no,toolbar=no,alwaysraised=yes,resizable=yes,scrollbars=yes
       
       
                      JSObject window = JSObject.getWindow(applet);
                      Object[] arguments = new Object[3];
                      arguments[0] = url;
                      arguments[1] = browserName;
                      arguments[2] = browserParams;
                      JSObject retObj = (JSObject)window.call("open", arguments);
                      if(isFocusReqd)
                          retObj.call("focus", null);
                      else
                          window.call("focus",null);
                      return retObj;
       
      As per the below link you provided showDocument() has 2 parameters. I didn't find a way to use it as per our requirement (pass parameter). It would be nice if you provide some idea to call showDocument() with parameters.
      http://download.oracle.com/javase/tutorial/deployment/applet/browser.html

      As I mentioned earlier, when we analyzed it more, found 2 work arounds, registry value change and code change. The registry change would certainly be unacceptable so gave a try to code change and modified the code as below but this work around is not working with IE8 . We were not sure about this work around and provided the specific fix.
       
                      JSObject window = JSObject.getWindow(applet);
                      Object[] arguments = new Object[3];
                      arguments[0] = url;
                      arguments[1] = browserName;
                      arguments[2] = browserParams;
                      JSObject retObj = (JSObject)window.call("open", arguments);
                      String jreVersion = CasaPrivilegeManager.getSystemProperty("java.runtime.version");
                      if(isFocusReqd){
                          if(jreVersion.indexOf("1.6.0_19")>-1 || jreVersion.indexOf("1.6.0_20")>-1 ){
                     window.call("blur",null);
                window.call("focus", null);
               }
               retObj.call("focus", null);
              }
                      else
                          window.call("focus",null);
                      return retObj;
       
      Please let me know if I missed any thing. I would appriciate your help.
      ***

      There is a test case provided by CITI as well as the
      one from the original bug report.




      A DESCRIPTION OF THE PROBLEM :
      Our application makes several calls from our applet to javascript functions defined on the hosting jsp page.

      One of the things these javascript functions do it to open a new browser window to navigate to different parts of the application (using javascript window.open()).

      In previous versions of the plugin these opened windows were created on top of the window hosting the applet. Since 6u10 the windows appear underneath the current window. Unless the user notices a new window has appeared on the taskbar they do not know something has happened.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an applet which calls a javascript function using JSObject.
      Define a javascript function which uses window.open to open a new browser window.

      Run applet, calling javascript function.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      New browser window appears on top of current window.
      ACTUAL -
      New browser window appears underneath current window.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      applet code as follows:

      import java.awt.FlowLayout;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javax.swing.JApplet;
      import javax.swing.JButton;
      import javax.swing.SwingUtilities;

      import netscape.javascript.JSObject;

      public class TestApplet extends JApplet {

          public void init() {
              super.init();
              
              Runnable r = new Runnable() {
                  public void run() {
                      createGUI();
                  }
              };
              try {
                  SwingUtilities.invokeAndWait(r);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
          
          public void createGUI() {
              getContentPane().setLayout(new FlowLayout());
              JButton button = new JButton("click me");
              button.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                     callJS();
                 }
              });
              getContentPane().add(button);
          }
          
          public void callJS() {
              JSObject.getWindow(this).call("myJSFunction", null);
          }
      }


      html code as follows

      <html>
      <head>
      </head>

      <script type="text/javascript">
      function myJSFunction() {
        window.open("http://java.sun.com", "_blank", "toolbar=no, menubar=no, scrollbars=yes, resizable=yes, status=yes, location=no");
      }
      </script>

      <body>
      <applet height="100%" width="100%" code="TestApplet" archive="." mayscript>
      </applet>

      </body>

      </html>

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                robm Robert Mckenna
                Reporter:
                dvanero Dennis Van Eron
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: