CancelImage Upload

How to find out if a browser has Java Enabled

Embedding a Java Applet is a pretty straight forward task. However, there is no point embedding an Applet if the browsers Java Component has been disabled. Here then is the JavaScript code to find out whether or not this has been the case. Note that we are talking about Java Applets here, not JavaScript. If JavaScript has been disabled you need to make use of noscript tags.

By using the object navigator we can call upon the function javaEnabled to see if the user has not disabled it. If it is up and running the following code will return true. If not it will return false:

navigator.javaEnabled()

Here is an example of how to deal with both the true and false outcomes:

<html>
<head>
<title>How to find out if a browser has Java Enabled</title>
<script language="JavaScript">

function getJavaStatus()
{

         var javaStatus = document.getElementById("javaStatus");

         if(navigator.javaEnabled())
         {

                  javaStatus.innerHTML = "Java is enabled.";

         }
         else
         {

                  javaStatus.innerHTML = "Java has been disabled.";

         }

}

</script>

</head>
<body onload="javascript:getJavaStatus();">

<span id="javaStatus"></span>

</body>
</html>


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com