Export (0) Print
Expand All

Supporting J# Browser Controls and Java Applets in the Same Page

Visual Studio .NET 2003
 

Visitors to many Internet Web sites are likely to be a mix of those running Internet Explorer and other non-Microsoft browsers. Many of these visitors will also be a mix of those who have J# Browsers Controls installed and those who only have the Java Virtual Machine installed. Web sites that need to support Java applets along with J# Browser Controls can specify both the J# Browser Control <OBJECT> tag as well as the Java applet tag in the same HTML page and let the appropriate tag run based on the browser version and whether J# Browser Controls is installed.

There are many possible ways of supporting J# Browser Controls and Java applets in the same HTML page. One solution is to use the HTML+TIME extensions that are supported from Internet Explorer 5.0. HTML+TIME (Timed Interactive Multimedia Extensions) enables selective display of elements in an HTML page depending on capabilities of the browser. HTML+TIME does not rely on scripting.

The following code snippet illustrates how HTML+TIME can to be used to selectively run J# Browser Controls or Java applets. In many cases, you can copy and paste the following code snippet into your HTML page and get it to work for you after changing the values of the appropriate attributes.

<HTML xmlns:t ="urn:schemas-microsoft-com:time">
<HEAD>
<STYLE>
.time { behavior: url(#default#TIME2); }
</STYLE>
<?IMPORT namespace="t" implementation="#default#time2">
</HEAD>
<!--[if gte IE 5.1]>
<t:excl>
<OBJECT class="time" 
id="JVM" 
begin="0;" 
dur="indefinite" 
timeAction="display" 
codetype="application/java" 
height=100 width=500 
classid="java:MyApplet.class">
<br>
<object class="time" 
id="JBC" 
begin="0;" 
dur="indefinite"  
timeAction="display" 
height=100 width=500 
  CLASSID="clsid:a399591c-0fd0- 41f8-9d25-bd76f632415f"
  VJSCODEBASE="MyAppletLibrary.dll#MyApplet">
<br>
</OBJECT>
</OBJECT>
</t:excl>
<![endif]-->

<![if lt IE 5.1]>
<APPLET class="time" 
id="JVM" 
begin="0;" 
dur="indefinite" 
timeAction="display" 
height=300 width=965 
code=MyApplet.class>
</APPLET>
<![endif]>
</HTML>

HTML+TIME tags are Internet Explorer extensions supported from version 5.0 and later. As these tags appear within comment blocks, they are ignored by non-Microsoft browsers and older versions of Internet Explorer. HTML pages using these extensions can therefore also render on older or non-Microsoft browsers.

The code snippet above has the following behavior when run in Internet Explorer 5.0 and later:

  • If both the J# Browser Controls runtime and a Java Virtual Machine are installed, then the J# Browser Control is run
  • If only the J# Browser Controls runtime is installed, then the J# Browser Control is run
  • If only a Java Virtual Machine is installed, then the Java applet is run.
  • If neither is installed, then a blank page is displayed.

When run in an older version of Internet Explorer or a non-Microsoft browser, then the Java applet is run.

The code snippet consists of two sections, one beginning with <!--[if gte IE 5.1]> and the other beginning with <![if lt IE 5.1]>. The code under <!--[if gte IE 5.1]> is only executed when the browser is Internet Explorer version 5.1 or above. The code under <![if lt IE 5.1]> is executed when the browser is a non-Microsoft browser or an older version of Internet Explorer. The <t:excl> tag of HTML+TIME ensures that no other tag is rendered if another tag has already been rendered. The <OBJECT> tag that gets rendered is the one that the browser is capable of rendering. this depends on whether either of J# Browser Controls or the Java Virtual Machine is installed on the computer. For a detailed description of the attributes used, refer to http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/time.asp!href(http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/time.asp).

See Also

Migrating Java Applets to Microsoft J# Browser Controls | Classes Accessible to a J# Browser Control | How to: Debug J# Browser Controls | Supporting J# Browser Controls and Java Applets in the Same Page

Show:
© 2014 Microsoft