Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Stop firefox from prompting to open jnlp file

843802Oct 25 2007 — edited Nov 5 2007
Love JWS!!

Works great for me on both IE and FF browsers using a little bit of JavaScript.

The only drawback I see is that Firefox will prompt the user to open file.jnlp with the default download/open dialog.

Anyone know how to prevent this?
Do you implement the JS in a manner that is different, allowing seamless function in FF too?

heres what my launch page looks like for the notepad example;
<html>
<head>
<meta http-equiv="Content-Language" content="en" />
<meta name="GENERATOR" content="PHPEclipse 1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Demo Web Launch</title>
<script language="JavaScript" type="text/javascript">  
var detect = navigator.userAgent.toLowerCase();
var windowsIE = (checkPlatform("msie") && checkPlatform("win"));
function checkPlatform(string)
{
    place = detect.indexOf(string) + 1;
    return place;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">
<script language="JavaScript" type="text/javascript">
  if (windowsIE) {
    document.write("<OBJECT codeBase=http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab classid=clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284 height=0 width=0>");
    document.write("<PARAM name=app VALUE=http://java.sun.com/products/javawebstart/apps/notepad.jnlp>");
	document.write("<PARAM NAME=back VALUE=false>");
	document.write("</OBJECT>");
 }
 if (navigator.mimeTypes && navigator.mimeTypes.length) {
	webstartAvailable = navigator.mimeTypes['application/x-java-jnlp-file'];
}
/*
if (!webstartVersionCheck("1.5")) {
     window.open("http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com",
        "needdownload");
}
*/
function webstartVersionCheck(versionString) {
    // Mozilla may not recognize new plugins without this refresh
    navigator.plugins.refresh(true);
    // First, determine if Web Start is available
    if (navigator.mimeTypes['application/x-java-jnlp-file']) {
        // Next, check for appropriate version family
        for (var i = 0; i < navigator.mimeTypes.length; ++i) {
            pluginType = navigator.mimeTypes.type;
if (pluginType == "application/x-java-applet;version=" + versionString) {
return true;
}
}
}
}
launchTID =setInterval('launchJNLP("http://java.sun.com/products/javawebstart/apps/notepad.jnlp")',
100);

function launchJNLP(app) {
if (webstartVersionCheck("1.5")) {
clearInterval(launchTID);
window.location = app;
}
}
</script>

</body>
</html>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2007
Added on Oct 25 2007
2 comments
329 views