Search code examples
javajavascriptappletdeployjava

Disable redirect to java.com on mobile when using deployJava.js


I'm using Java Deployment Script on my web application using this code.

<script src="https://www.java.com/js/deployJava.js"></script>
<script>
    var attributes = {
        code:'applet.class',  width:0, height:0,separate_jvm: false,id:'applet'} ;
    var parameters = {jnlp_href: 'jnlp.jnlp'} ;
    deployJava.runApplet(attributes, parameters, '1.7');
</script>

The issue occurs when I try to view this page on Mobile Browser.

deployJava.runapplet checks for current installed on the browser/System, but as mobile browsers don't have hava(ios and android) it redirects it to java install page, which also informs that there is not java available.

So the user is not able to view the page entirely.

I want some way to disable java check on mobile browsers.


Solution

  • I see you are using the deployJava.js file also known as the 'Deployment Toolkit Script'.

    So you can simply use the getJREs() function provided by that script to check if there are installed JREs before calling the runApplet() function.

    You can also use the Detect Mobile Browsers lib to check if the user is on a mobile browser