How to check If Java Is Enabled with JavaScript

Home arrow HTML & CSS Tutorials arrow Javascript arrow How to check If Java Is Enabled with JavaScript
How to check If Java Is Enabled with JavaScript Print E-mail
Contributed by Joe   
Friday, 21 July 2006

Why check If Java Is Enabled with JavaScript

Sometimes you have to know whether or not Java is enabled JavaScript provides a simple mechanism for determining this: the navigator.javaEnabled method. This method returns true if Java is enabled in the browser and false otherwise.

Example of Checking  If Java Is Enabled with JavaScript

  •  Create a new HTML document.with a script block:

<body>
<script language=”JavaScript”>
<!--
// -->
</script>
</body>

  • In the script block, call navigator.javaEnabled and assign the results to a variable:

<body>
<script language=”JavaScript”>
<!--
var ifJava = navigator.javaEnabled();
// -->
</script>
</bod

  • Use document.write to display a relevant message

<body>
<script language=”JavaScript”>
<!--
var haveJava = navigator.javaEnabled();
document.write(“Java is enabled: “ + ifJava);
// -->
</script>
</body>

  • Open the file in a browser

If  java senable  in your browser, you will see "Java is enabled. true".

Related Articles

Javascript Cookie

Last Updated ( Friday, 21 July 2006 )

  home              contact us

 

©2006-2008 DeveloperZone.biz   All rights reserved     powered by Mambo Designed by Siteground