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

Javascript in Frames Causes MalFormed URL in Plug-in

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.1.3
    • Fix Version/s: None
    • Component/s: deploy
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description

      ** THIS BUG IS FILED TO SUPPORT AN ESCALATION **

      The plug-in version is 1.1.3 running on NT 4.0. Browsers used are Netscape 4.7
      and IE 5.0.

      The customer is attempting to run javascript in frames that loads an applet in
      either IE or Netscape.

      In the test case below, applet loading aborts with the following error messages:

      In Netscape 4.7,

      Request focus
      java.net.MalformedURLException: unknown protocol: about
      at java.net.URL.<init>(Compiled Code)
      at java.net.URL.<init>(URL.java:246)
      at sun.plugin.navig.win32.PluginObject.setDocumentURL(PluginObject.java:201)

      In IE 5.0,

      java.net.MalformedURLException: unknown protocol: javascript
      at java.net.URL.<init>(Compiled Code)
      at java.net.URL.<init>(URL.java:246)
      at sun.plugin.ocx.ActiveXAppletViewer.setDocumentBase(ActiveXAppletViewer.java:171)

      If you replace the phrase "src=javascript..." in the html page with
      "src=anything.html", the second html page loads properly.

      ------------------------------- pluginExample.html -----------------------------

      <html>
      <head>
      <title>COMPAS Document Management System</title>

      <script language = "JavaScript">
      <!--

      function doHidden()
      {
      // dummy frame to hold object, embed, and applet tags
      var doc = hidden.document;
      doc.writeln('<html></html>');
      doc.close();
      }

      function doIEPlugin()
      {
      /*
      ** Output the internet explorer Java Plugin tag.
      */
      var doc = hidden.document;

      doc.writeln('<object classid='
      + '"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"');
      doc.writeln('width="200" height="200" align="baseline"');
      doc.writeln(' codebase="javascript:parent.doApplet()"> ');

      doc.writeln('<param name=code value="UIApplet1.class">');
      doc.writeln('<param name=archive value="swing.jar">');
      doc.writeln('<param name=codebase value=".">');
      doc.writeln('<param name=type value=');
      doc.writeln('"application/x-java-applet;version=1.1.3">');
      doc.writeln('</object>');
      }

      function doNSPlugin()
      {
      var doc = hidden.document;

      doc.writeln('<embed');
      doc.writeln(' type="application/x-java-applet;version=1.1.3"');
      doc.writeln(' width="200" height="200"');
      doc.writeln(' align="baseline" code="UIApplet1.class"');
      doc.writeln(' codebase="."');
      doc.writeln(' archive="swing.jar"');
      doc.writeln(' pluginspage="javascript:parent.doApplet()"');
      doc.writeln('<noembed> ');

      doc.writeln('<script language="JavaScript">');
      doc.writeln('parent.doApplet();</script>');
      doc.writeln('</noembed></embed>');
      }

      function showPlugin()
      {
      /*
      ** Variables to detect which browser
      ** is used.
      */
      var _info = navigator.userAgent;
      var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0
      && _info.indexOf("Windows 3.1") < 0);
      var _ns = (navigator.appName.indexOf("Netscape") >= 0
      && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0
      && java.lang.System.getProperty
      ("os.version").indexOf("3.5") < 0)
      || _info.indexOf("Sun") > 0));

      if (_ie == true)
      {
      doIEPlugin();
      }
      else if (_ns == true)
      {
      /*
      ** If Netscape doesn't have the Java Plug-in, then
      ** it does not fail gracefully by calling our doApplet
      ** function. So the following fixes that.
      */
      if (navigator.plugins[
      "Java Plug-in 1.1.3 for Netscape Navigator"] == null)
      {
      doApplet();
      return;
      }
      doNSPlugin();
      }
      else
      {
      doApplet();
      }
      }

      function doApplet()
      {
      /*
      ** Output the applet tag. The user must not
      ** have the Java Plug-in installed.
      */
      var doc = hidden.document;

      doc.writeln('<br>');
      doc.writeln('<applet code="UIApplet1.class" ');
      doc.writeln('archive="swing.jar">');
      doc.writeln('</applet>');
      }

      //-->
      </script>
      </head>

      <frameset rows = "100%,*" frameborder = 0 framespacing = 0 border = 0>
      <frame name = "main" src="javascript:parent.showPlugin()">
      <frame name = "hidden" src="javascript:parent.doHidden()">
      </frameset>

      </html>

      ----------------------------------- UIApplet1.java -----------------------------

      import java.awt.*;

      import javax.swing.*;
      import javax.swing.plaf.ColorUIResource;

      public class UIApplet1 extends JApplet {
        public void start() {
          Container c = getContentPane();
          ColorUIResource colResource = new ColorUIResource(Color.blue);
          // Change some defaults.
          UIManager.put("ScrollBar.background", colResource);
          UIManager.put("ScrollBar.thumb", colResource);
          UIManager.put("ScrollBar.width", new Integer(40));
          c.setLayout(new BorderLayout());
          c.add(new JScrollBar(), BorderLayout.WEST);
        }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                myangsunw Mingyao Yang (Inactive)
                Reporter:
                nrodinsunw Nick Rodin (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: