...

View Full Version : Simple flash detection to write to form



OzWhack
06-25-2004, 05:39 AM
Hi, I'm trying to make this script to write values to a form. The browser, platform and screen res works fine, but the flash detection returns as No even though flash plugin is present.

<SCRIPT LANGUAGE="JavaScript">

function display() {
window.onerror=null;

document.form.browser.value = navigator.appName;
document.form.platform.value = navigator.platform;
document.form.width.value = window.screen.width;
document.form.height.value = window.screen.height;

if (window.flashinstalled) document.form.flash.value="Yes";
else document.form.flash.value="No";
}
</script>

I'm all new to javascripting (as you can see), so I'd really appreciate a simple answer (if there is one) :D
Tried to find a solution in the forum, but couldn't find what I need...

Cheers!
Lars

glenngv
06-25-2004, 07:17 AM
http://www.skyzyx.com/scripts/flash.php

OzWhack
06-25-2004, 08:01 AM
Thanks Glenn, but I still don't get it to work. The script is too complex for me to understand, but I tried to follow the instructions. I saved the flash.js and added these scripts to my head;

<script language="JavaScript" type="text/javascript" src="flash.js"></script>
<script language="JavaScript" type="text/javascript">
<!--

if (flash.ver[6])
{
document.form.flash.value="Yes";

}
else if (flash.installed)
{
document.form.flash.value="Yes";

}
else
{
document.form.flash.value="No";

}

//-->
</script>

glenngv
06-25-2004, 08:13 AM
I think you're accessing the flash field before it is even loaded to the page. You should set the field once the page has loaded. You should do it on onload. And you're only interested if the browser has flash or not, not in the version, so you don't need to check flash.ver[n] values, only the flash.installed property.

window.onload = function(){
document.form.flash.value = (flash.installed) ? "Yes":"No";
}

OzWhack
06-25-2004, 08:34 AM
Thanks again Glenn, but it still returns as No, both on mac (safari, explorer and mozilla), and win (explorer). Any other suggestions?

Lars

glenngv
06-25-2004, 08:46 AM
Can you view Skyzyx site again using those browsers and see if his code works.
There is a sample output in that page that checks the plugin of the browsers used.

OzWhack
06-25-2004, 09:29 AM
All the browsers get a result on skyzyx, so I guess it's my implementation that fails...

glenngv
06-25-2004, 10:18 AM
So could you post your codes then?

OzWhack
06-25-2004, 10:57 AM
This is where I'm at with the skyzyx code. I have tried it in different combinations of head and body, and also with and without the flash.js, but it either returns nothing or No. My apologies if I'm being slow...


<script language="JavaScript" type="text/javascript" src="../flash.js"></script>
<script language="JavaScript" type="text/javascript">
<!--

window.onload
if (flash.installed)
{
document.form.flash.value="Yes";
}

else
{
document.form.flash.value="No";
}

//-->
</script>

glenngv
06-25-2004, 11:08 AM
<html>
<head>
<script language="JavaScript" type="text/javascript" src="../flash.js"></script>
<script language="JavaScript" type="text/javascript">
<!--

window.onload = function() {
if (flash.installed)
{
document.form.flash.value="Yes";
}
else
{
document.form.flash.value="No";
}
}
//-->
</script>
</head>
<body>
<form name="form">
<input type="text" name="flash" />
</form>
</body>
</html>

Make sure that the path of the flash.js file is correct.
Check for possible js errors in Javascript console (NS/Moz) or error notification in IE (double-click "!" icon in the status bar, if any)

OzWhack
06-25-2004, 12:53 PM
Thank you, it needed a little tweak to get it to work together with other scripts, but now it works like a charm! :thumbsup:
Thanks again!
Lars



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum