Hi to all,
Hope you all are fine.I have a javascript to check whether java is installed or not on your system.The code is

<body>
<script language="Javascript" type="text/javascript">
       if(!navigator.javaEnabled()){
             alert('Enable your java to expeirience this java enhanced page  or\n try install it...');
             location.replace('http://java.sun.com');
             window.open('instructionsforintallingjava.html');
        }
        else{
              document.write('<applet watever></applet>');
         }
</script>
<noscript>
Enabled javascript please
</noscript>
</body>

The problem is this work fine in my browser firefox and internet explorer8 but in old internet explorer browser and a new browser named fix browser and some version of firefox also this won't work, can any one tell me why this is happening and how can i overcome this.
Also in the

location.replace('installing java.html');

i have an applet in case when applet doesn't appear this installing page instruction appear in place of applet. I show a link in the replace location.
The problem is when i clink on this link it open page in the small portion reserve for applet. I want when people click on this link it open in the new page. Please tell me how i do this also.
Thanks in advance

Recommended Answers

All 8 Replies

Hi,

you can try this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>www.daniweb.com</title>
</head>
<body>
<noscript>
<p> This site requires a browser that support <b>JavaScript</b>. </p> 
</noscript>
<div id="div0">
<script type="text/javascript">
<!--
( function() {
   var applet = "applet"
   if( "navigator" in window ) {
      if ( navigator.javaEnabled() ) {
         if ( "createElement" in document ) {
            return ( function( ) {
            applet = document.createElement( applet );
            applet.setAttribute( "code", "someclass.class" );
            document.getElementById("div0").appendChild((( document.createDocumentFragment()).appendChild( applet )));
         } )( );
         } document.writeln( "<" + applet + " code=\"someclass.class\"></" + applet + ">" );
      return;
      }
   } alert( "Enable your java to experience this java enhanced page or\ntry install it..." );
   location.href = "http://java.sun.com";
   window.open( "instructionsforinstallingjava.html", "JAVA Installation Manual", "width=500, height=500, location=0, scrollbars=1, toolbar=0" ); 
} )( );
// -->
</script>
</div>
</body>
</html>

Hi,
Thanks for your help.Actually i forgot to tell you my applet called using PHP. I try your code in the local system it works fine as i want but in actual the coe that i use is look like as follows

<?php 
 $id = $_GET['Uniqueid'];
 $uname = $_GET['Username'];
 ?>

<script language="JavaScript">
<!--
function test()
{
        var UNI = document.applets.TestApp;
        var subor = UNI.getFile();
	alert(subor);
	 return false;
}
-->
</script>
<head>
 <body>
<script language="Javascript" type="text/javascript">   
         if(!navigator.javaEnabled()){
              alert('Enable your java to expeirience this java enhanced page or\n try install it...');
          window.open('JAVAInstall.php');
          //location.replace('http://java.sun.com');
          location.replace('InstallingJAVA.html');
       }
</script>
<noscript>
Enabled javascript please
</noscript>

<?php

$applet='<APPLET CODE = "CapturePlayback1.class" ARCHIVE = "CapturePlayback1.jar" WIDTH = "240" HEIGHT = "210" NAME = "Bxxx" MAYSCRIPT = true>
       <PARAM NAME="uid"  VALUE="'.$id.'">
      <PARAM NAME="uname"    VALUE="'.$uname.'">
</APPLET> ';
echo $applet;
?>
</body>
</head>

Your code works fine, I try it on IE 6 the above code is not working with IE 6 but your code works fine but how can i use these PHP statements in your code , can you please help me?
Thank you very much

Hi terry,

apply the following procedure below, inside your PHP page:

<?php 

$id = $_GET['Uniqueid'];
$uname = $_GET['Username'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>W3C Standard Template :: HTML 4.01 ( loose-dtd )</title>
</head>
<body>
<noscript>
<p> This site requires a browser that support <b>JavaScript</b>. </p> 
</noscript>
<div>
<script type="text/javascript">
<!--
( function( obj ) {
   if ( "navigator" in window ) {
      if ( navigator.javaEnabled() ) {
      try {
         if ( "createElement" in document ) {
         var body = document.getElementsByTagName( "body" )[ 0 ];
         var fragment = document.createDocumentFragment();
         var isTag = obj.match(/(applet|param)(?=\s)/ig);
         var isAttribute = obj.match(/(?!(applet|param)\s)\w+[\s=]+(^|)["\w\.]+(\w+)("|\w+(?=>))/ig);
         var isAttribution = new Array( isAttribute.length );
            for ( var i = 0; i < isAttribute.length; i++ ) {
            var trimAttr = ( isAttribute[ i ].split(/[\s"]+/)).join("");
            trimAttr = trimAttr.split("="); 
            isAttribution[ i ] = trimAttr;
            } var node = new Array( isTag.length ); 
            for ( var o = 0; o < isTag.length; o++ ) {
            node[ o ] = document.createElement( isTag[ o ].toLowerCase() );
            node[ 0 ].appendChild((( o > 0 ) ? node[ o ] : void( 0 ))); 
            } 
            for ( var prop in isAttribution ) {
            var props = isAttribution[ prop ];
            var thisAttribute = props[ 0 ].toLowerCase();
               if ( prop < 6 ) 
                  node[ 0 ].setAttribute( thisAttribute, props[ 1 ] );
               else if ( prop < 8 ) 
                  node[ 1 ].setAttribute( thisAttribute, props[ 1 ] ); 
               else 
                  node[ 2 ].setAttribute( thisAttribute, props[ 1 ] ); 
            } 
         body.appendChild(( fragment.appendChild( node[ 0 ] )));
         return;
         } throw "cantCreateElement"; 
      } catch( e ) { 
         if ( e === "cantCreateElement" ) {
      document.writeln( obj );
      return;
         }
      } 
   } alert( "Enable your java to expeirience this java enhanced page or\n try install it..." );
      location.href = "http://java.sun.com/";
      window.open( "JAVAInstall.php", target = "_blank", "Installing JAVA Application", "width=500, height=500, location=0, toolbar=0,scrollbars=1");
   }
} )( <?php
/* [b]PHP Syntax[/b] */
 print '\'<APPLET CODE= "CapturePlayback1.class" ARCHIVE = "CapturePlayback1.jar" WIDTH = "240" HEIGHT = "210" NAME = "Bxxx" MAYSCRIPT = true><PARAM NAME="uid" VALUE="'.$id.'"><PARAM NAME="uname" VALUE="'.$uname.'"></APPLET>\''; ?> ); 

// -->
</script>
</div>
</body>
</html>

Hi essential :icon_smile: ,
Hope you will be fine. First of all thank you very much for your help. I try your script but there is a problem i don't no why this is happening actually if i try your code its show an alert if i have java installed , its not work on internet explorer 6 i think its a different issue its not script specific, yes your script solve the problem of different versions of firefox, but please check your script why it shows an alert if java is installed, i try different things but i am not succeeded. In IE6 it shows a message object doesnot support this property or method, i search the error and i found IE cause problem for some reasons i check it out , on IE 7 i try it with out java installed its work perfectly fine , on my system i have IE 8 and java too and it shows an alert that you use in your script . So please check it why this is happening.
One thing more if i place this file in a server and then run it by giving url of the file such as http//www.abc.com/voicemail/CapturePlayback1.php it works on IE 6 but when i run the file through the email client where i place the recorder nothing shows on IE 6 but with a error that i already told you above.
Again thanks for your help and time :icon_smile: .
Thank you.

Hi terry,

here's the another version of the code and workout things with your applet tags:

test.php:

<?php 
 $id = $_GET['Uniqueid'];
 $uname = $_GET['Username'];
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>Terry's Test Page PHP</title>
</head>
<body>
<noscript>
<p> This site requires a browser that support <b>JavaScript</b>. </p> 
</noscript>
<div id="content">
<?php
   $applet = '<APPLET  CODE= "CapturePlayback1.class" ARCHIVE = "CapturePlayback1.jar" WIDTH = "240" HEIGHT = "210" NAME = "Bxxx" MAYSCRIPT = true>';
   $applet .= '<PARAM NAME="uname" VALUE="'.$id.'"><PARAM NAME="uname" VALUE="'.$uname.'"></APPLET>';

?>

<script type="text/javascript">
<!--
function parse( xml ) {
   try {
     var xmlDOM = new ActiveXObject("Microsoft.XMLDOM");
      xmlDOM.async = "false";
      xmlDOM.loadXML( xml );
   } catch( e1 ) {
      try {
         var Applets = new DOMParser();
         var xmlDOM = Applets.parseFromString( xml, "text/xml" );
      } catch( e2 ) {
        var xmlDOM = 0;
      }
   } if ( xmlDOM ) { 
     var clone = xmlDOM.documentElement;
     var div = document.getElementById( "content" );
     var cloned = document.importNode( clone, true )
     var fragment = document.createDocumentFragment();     
     fragment.appendChild( cloned );
     div.appendChild( fragment );
  
   } else {
      document.write( xml );
   }
}
function welFormedApplet( Applet ) {
   if ( Applet ) { 
   var pattern = /\w*\s*=\s*/g;
   var compiler = Applet.match( pattern );
   var splitter = ( compiler.join("").split(/\s*=\s*/));
   var x, len;
      for ( x = 0, len = compiler.length; x < len; x++ ) {
      Applet = Applet.replace( compiler[ x ], splitter[ x ] + "=" );    
      } var pattern = /\w+=\w+/g;
      compiler = Applet.match( pattern );
      for ( x = 0, len = compiler.length; x < len; x++ ) {
      Applet = Applet.replace( compiler[ x ], String(( compiler[ x ].split("=") ).join("=\"") + "\"" ));       
      } var pattern = /<param\s(\w+|\w+\-\w+)([\=\w\-\"\s\;\/]+)>/ig;
      compiler = Applet.match( pattern );
      for ( x = 0, len = compiler.length; x < len; x++ ) {
      Applet = Applet.replace( compiler[ x ], String((compiler[ x ].split(">")).join(" />")));
      } parse( Applet );
   } 
} 
( function() {
var java;
var alertMessage = "\nEnable your java to expeirience this java enhanced page.";
   try {   
      java = ( window.navigator.javaEnabled() ) ? "enabled" : "disabled";   
   } catch( e ) { java = false; }
   if ( typeof( java ) !== "boolean" ) {
      if ( java === "enabled" ) {
      var applet = '<?php echo $applet; ?>';
      welFormedApplet( applet );
      return;
      } if ( confirm( "java-disabled : install it now?" )) {
      var javasun = new Image();
      javasun.src = "http://java.sun.com";
      window.location = javasun.src;
       } else {
       alert( alertMessage );
       window.open( "JAVAInstall.php", "Installing JAVA Application", "width=500, height=500, location=0, toolbar=0,scrollbars=1" );
      } return 0;
   } alert( "java-plugin is not supported in your browser\nfor more information plese visit : http://java.sun.com/" );
   return 0;
} )() 
//-->
</script>
</div>
</body>
</html>

you can see this page in action by clicking here!

Hi Essential,
Hope you will be fine, Sorry for late reply actually i was solving another problem and the problem is the recorder for which you write scripts for me :P is not attaching the files , i solved it, the problem is the uniqueid parameter $id = $_GET; is not generated, i don't no why it was happened but somehow i manage to solve it.
I tried your script but it's give me XML parsing error, This time i m attaching a file so you get better understanding how my recorder is display in the page, the place where error is shown, looks blank when the recorder is not shown.
Another problem is that you'll see its a small box so when something goes wrong the people unable to read the whole thing as it is happened in this case also, you couldn't see the whole error because it is going outside the window, the same thing happen if you use location.replace, its open the page in the small square and people unable to read any thing.Actually its a blank page whose called in an iframe and the code is

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>
</head>
<body bgcolor="#ffffff">
<script language="Javascript" type="text/javascript">

   if(!navigator.javaEnabled()){
      alert('Enable your java to expeirience this java enhanced page or\n try install it...');
      window.open( "http://www.java.com/en/download/index.jsp", "JAVA Installation Manual", "width=500, height=500, location=0, scrollbars=1, toolbar=0" ); 
   }
</script>
<noscript>
Enabled javascript please
</noscript>
<div id="body">
</div>
</body>
</html>

If you remove the JavaScript then this is the page that is shown when recorder is not shown. I add script here to see whether its work or not and if change the condition then read below what happened.
Another thing that may be helps you is this you'll see in the attachment is the compose and voice mail. Actually when you click on compose its open a page n if you click on voice mail its open the same page with recorder in it, purporting voice mail page is same as compose page but recorder is added in the voice mail, so i want to ask is it a conflicting issue of somethings between these two pages.
Another thing i tried and this is very strange, what happened one of my user, java is not installed, he is also using IE 6, its the same person,when i try your script, it don't work on his computer, I locally try java check script on his system. I simply use the condition if java is not installed then pop up a message, this local script works fine on Firefox, he also contain Firefox in his system, but when i try the script in IE it didn't show any message, the strange thing is this when i change the condition, if java installed then pop a message, then his IE pop up a message and is just shown as i click on compose page means i don't enter in the voice mail and it shows message two times but in Firefox until i click on the voice mail it didn't show any message , and i m unable to understand why it is happening, because he has no java at all.
Also the only tag that i supposed to set is the name parameter in the applet tag and i set it before trying your script.
So this is the whole story and its long enough :)
But thank you very much for your help
Thank You :)

Hi to all,
I come to know that (navigator.javaEnabled()) not actually check java in your system in IE, and i also known why it is throwing message when i change condition to (navigator.javaEnabled()), so any one tell me how can i check whether java is installed on your system or not in IE.
Thank you

Hi to all,
Hope all are fine.I solved my problem with the script provided on sun site.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title></title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript"> 
var javawsInstalled = 0;  
var javaws142Installed=0;
var javaws150Installed=0;
var javaws160Installed = 0;
isIE = "false"; 
if (navigator.mimeTypes && navigator.mimeTypes.length) { 
   x = navigator.mimeTypes['application/x-java-jnlp-file']; 
   if (x) { 
      javawsInstalled = 1; 
      javaws142Installed=1;
      javaws150Installed=1;
      javaws160Installed = 1; 
  } 
} 
else { 
   isIE = "true"; 
} 
</SCRIPT> 

<SCRIPT LANGUAGE="VBScript">
on error resume next
If isIE = "true" Then
  If Not(IsObject(CreateObject("JavaWebStart.isInstalled"))) Then
     javawsInstalled = 0
  Else
     javawsInstalled = 1
  End If
  If Not(IsObject(CreateObject("JavaWebStart.isInstalled.1.4.2.0"))) Then
     javaws142Installed = 0
  Else
     javaws142Installed = 1
  End If 
  If Not(IsObject(CreateObject("JavaWebStart.isInstalled.1.5.0.0"))) Then
     javaws150Installed = 0
  Else
     javaws150Installed = 1
  End If  
  If Not(IsObject(CreateObject("JavaWebStart.isInstalled.1.6.0.0"))) Then
     javaws160Installed = 0
  Else
     javaws160Installed = 1
  End If  
End If
</SCRIPT>

<script language="JavaScript">
/* Note that the logic below always launches the JNLP application
 *if the browser is Gecko based. This is because it is not possible
 *to detect MIME type application/x-java-jnlp-file on Gecko-based browsers. 
 */
if (javawsInstalled || (navigator.userAgent.indexOf("Gecko") !=-1)) {
    document.write("");
} else {
    window.alert("Please enable your java to experience this enhanced page. If you don't have java Version 6 update 12 or higher installed please install it by clicking the \"Free Java Download\" link in the next window and incase new window don't open then copy this url to adress bar and download java by clicking the \"Free Java Download\" \nhttp://www.java.com/en/download/index.jsp");
    location.replace("Java2.html");
    window.open( "http://www.java.com/en/download/index.jsp", '', "width=1000, height=1000, location=0, scrollbars=1, toolbar=0" );    
}
</SCRIPT>

</body>
</html>

Actually in window.open if i use second parameter then it's not working on IE8 so i make it null, it's opening window now but not on first attempt when i come to the page it gives an alert replace it and then nothing happen but when i come to second time on it it opens a new window. Any way this script is working for me.
Thank you specially to essentail :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.