|
How can you discover which browser the client station is running ? This is pretty simple but not always easy to find. I read in a newsgroup a tip and then developed a full scale, JavaScript and Java solution to this problem. Click here to discover your browser JavaScript JavaScript is essential to solve this puzzle. There is a very detailed article at http://www.microsoft.com/workshop/management/sniffing.asp . I used the JavaScript code there to discover the browser. But that's not all, after you have the JavaScript, you need to display the result to the user. There are many ways of doing that (it's also explained in the article). I opted to use a Java applet to display the results. So, the first big question is: how can a Java applet be called from a JavaScript ? You just need to use the following tag when defining your applet <applet width="452" height="76" code=[appletName].class name=[appletName] codebase="applets/">My applet is called, EnvironmentApplet, so it is just replace appletName by EnvironmentApplet, and we have the following tag : <applet width="452" height="76" code="EnvironmentApplet.class" name="EnvironmentApplet" codebase="applets/">Once you have defined the applet's name in the applet tag (see name in the example above), you can now call the Java applet and access its public methods : document.EnvironmentApplet.setIE4(bMSIE4);Java And the Java applet ? We need to be able to show the client which browser is running in his/her machine. A good way of displaying that is to use radio buttons, one for each browser. I set up 5 buttons, two for Internet Explorer (3.0 and 4.0), two for Netscape (3.0 and 4.0) and one for any other browser there is. The public methods just change the state of the radio button, whether it is selected or not (I created the radio buttons disabled, because we're displaying information the user cannot alter) : public void setIE4(boolean b) { this.rbIE4.setState(b); } Code Download The code for both the JavaScript and Java can be downloaded here:
|