home forums resources search newsjoinmembers: 6448
Hiveminds Network PHP Flash Java Ruby Windows Linux
 videos
 articles
 blogs
 comments
 downloads
sitemap
Hiveminds | Thu, 2007-11-08 16:07  tags: ,

This does not actually check for java on the machine. It just checks to see if the browser has java on or off. PHP cannot do this alone being a server-side language so you need to implement this using javascript under PHP.

You also have to be a little bit clever and set the script up so that the output is placed in a javascript variable that is readily available to PHP.

<?php

$output 
.= '
    <script language="JavaScript">
      var haveJava = navigator.javaEnabled();
      document.write("<br>Is Java is enabled ? : " + haveJava);
    </script>'
;

?>

I needed both a check for javascript and one for java. I managed to do this by using javascripts redirect and a built in javascript check for java enabled browsers. The following is a Drupal function but can be moded to suit any other PHP need.

<?php

function jupload_start(){
    global 
$user$base_url;
    
$output '
    <script type="text/javascript">
      var haveJava = navigator.javaEnabled();
      if (haveJava) {
          document.write(" Java and javascript check are okay");
          window.location.href = "'
.$base_url.'/?q=jupload/view&java=yes"; 
      }
      else {
          window.location.href = "'
.$base_url.'/?q=jupload/start&java=no";
      }
      </script>'
;
      
$output .= '<noscript> Your browser must have javascript enabled.</noscript>';
      print 
theme('page'$output); 
  }
?>

printer-friendly version

Hiveminds's picture
This article brought to you by the Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously
 
Joomla! Silverlight Web Developers Joomla! eRuby Content Management Systems
 

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.

page top