Microsoft KB Archive/884763

From BetaArchive Wiki

Article ID: 884763

Article Last Modified on 12/14/2004



APPLIES TO

  • Microsoft Internet Explorer 6.0
  • Microsoft Internet Explorer 5.0



SYMPTOMS

When you view your Web program in Microsoft Internet Explorer, you may experience errors. This symptom occurs if the following conditions are true:

  • Your Web program passes JavaScript URLs through the showDocument method of the Sun Microsystems Java plug-in.
  • You previously installed the security update that is described in Microsoft Knowledge Base article number 867801. For additional information about this security update, click the following article number to view the article in the Microsoft Knowledge Base:

    867801 MS04-025: Cumulative security update for Internet Explorer


CAUSE

This issue occurs because the Sun Microsystems Java plug-in cannot run JavaScript URLs by using the showDocument method after you install the MS04-025 security update.

RESOLUTION

To resolve this issue, contact Sun Microsystems to inquire about the availability of a fix for this issue.

Important As of September 2004, Sun Microsystems is developing an update for the Sun Microsystems Java plug-in that will make it possible for the plug-in to run JavaScript URLs.For information about how to contact Sun Microsystems, click the appropriate article number in the following list to view the article in the Microsoft Knowledge Base:

65416 Hardware and software vendor contact information, A-K

60781 Hardware and software vendor contact information, L-P

60782 Hardware and software vendor contact information, Q-Z


Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

WORKAROUND

To work around this issue, site authors can change their HTML. Site authors can replace a call to the showDocument method by using the JavaScript URL with a call to the showDocument method to a frame on the same domain. On this domain, when Internet Explorer loads the frame, Internet Explorer runs the onLoad method of the frame which causes the JavaScript URL to run.

The sample code in this article contains a modified workaround that makes it possible for the showDocument method to generate the result that you want. This sample is also generalized so that a window name can be used as a parameter to the showDocument method.

To use the workaround, the site author must author an HTML file with a pre-determined line of workaround script. The site author must add an additional hidden workaround frame and a script call to the HTML code on the page that uses the Java program.

The proposed workaround may not work if you have enabled the pop-up blocker and if the JavaScript URL tries to open other windows by using window.open method calls. You can overcome this problem by disabling or configuring the pop-up blocker.

Additions to the HTML page that contains the Java program

  • Add a frame to the existing HTML page that contains the Java program. In the workaround, this frame will be the target that is supplied to the showDocument method to open the workaround HTML page.
  • Include a JavaScript method that is used to call the window.open method. This method is called from the workaround HTML page when the onload event of its body object is initialized. The workaround HTML page is described in the "New workaround page" section.
//This is the additional "named" iframe to cause Internet Explorer to load the HTML code 
//that will call window.open with InvokeEx directly.
<IFRAME ID="workaroundFrame" NAME="workaroundFrame" WIDTH=0 HEIGHT=0></IFRAME> 
 
 //HTML code that will cause Internet Explorer to directly call window.open with InvokeEx
function doExecScript(){
                       fname = document.Test.getScriptFrameName();
                       window.open('javascript:' + document.Test.getScriptParam(), fname);
                                 }

New workaround page

You can add a workaround HTML page that is called from the Java program by using the showDocument method. This page is opened in the workaround frame that has been added to the HTML page that contains the Java program. The loading of the workaround page into the frame is performed by the Java program during the call to the showDocument method. The body object onload event for the workaround HTML page is set to call to the JavaScript method that is contained in the frame's parent. The frame's parent is the existing HTML page that contains the Java program. This process makes it possible for Internet Explorer to call to the window.open method by using the InvokeEx method directly, and this makes it possible to run a JavaScript URL.

//This is the single line of HTML code in the workaround frame that lets Java indirect through HTML.
<BODY ONLOAD="javascript:parent.doExecScript()">
 

Changes to the Java code

In the workaround, additional private fields are added to the Java program's class to store the URL and frame that would have originally been passed to the showDocument method. The sample code demonstrates how to use accessor methods such as getScriptParam and getScriptFrameName to make these values available to the JavaScript code (the doExecScript method in the workaround sample) that is contained in the HTML page that hosts the Java program. This makes it possible to call the window.open method by using these values.

//These are the variables that hold the JavaScript: URL and 
//the frame name that would have been passed to showDocument previously.
        private String strParam = "";

private String strParamFrame = "_self";
public void execute(String jsurl, String fname) {
            strParamFrame = fname;
            strParam  = jsurl;
//Change the call to showDocument to open the workaround HTML page in 
//the workaround frame by replacing 
//getAppletContext().showDocument(javascript url, "window name"); 
getAppletContext().showDocument(new URL(“workaroundPage.htm”), "workaroundFrame");
}
  public String getScriptParam()
  {
        return strParam;
  }
  public String getScriptFrameName()
  {
        return strParamFrame;
   }

MORE INFORMATION

The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

Keywords: kbinfo kbtshoot kbappcompatibility kbsamplepro kbcodesnippet kbappdev kbprogramming kbjava kbweb kbappsetup kbsecurity kbprb kbsample kbhtml kbsecbulletin kbcode kbbrowsing kbupdateissue KB884763