Identify OS, Browser Type and Version
Here is a short script that returns the users operating system (Win or Mac), browser and version. You can drop it into your web page between the <HEAD> tag and the <TITLE> tag.
<script language="JavaScript">
OSName = "unknown";
bName = "unknown";
bVer = "unknown";
if (navigator.appVersion.indexOf("Mac") > 0) OSname = "Mac";
if (navigator.appVersion.indexOf("Win") > 0) OSname = "Win";
if (navigator.appName.substring(0,8) == "Netscape")
bName = "NN";
if (navigator.appName.substring(0,9) == "Microsoft")
bName = "IE";
if (parseInt(navigator.appVersion) >= 3) bVer="3x";
if (parseInt(navigator.appVersion) >= 4) bVer="4x";
if (parseInt(navigator.appVersion) >= 5) bVer="5x";
</script>
Use <EMBED> or <A HREF>
This JavaScript uses <EMBED> for Explorer 4.x and later, and for all versions of Netscape browsers, but uses <A HREF> for earlier versions of Explorer, based on the results from the script above. Insert this bit of JavaScript into your web page where the <EMBED> or <A HREF> tag would go. Change the parameters inside the tags, such as SRC, HEIGHT and WIDTH, to match your movie, and add any other parameters you might need, such as HIDDEN or AUTOPLAY.
<script language="JavaScript">
if (bVer == "4x") || (bVer == "5x") || (bName == "NN")
document.write("<embed src=qtweb.mov height=176 width=130>") ;
else document.write("<a href=qtweb.mov> Play Movie </a>");
</script>
Open a Window for QuickTime
Here is a script for a function named openqtwin. When invoked, this function opens a 240 x 120 window named qtwin. This script should be placed between the <HEAD> and </HEAD> tags on your Web page.
<script language="JavaScript">
<!
function openQTwin(url) {
qtwin = window.open(url,"song",toolbar=0,location=0,
directories=0,status=0,menubar=0,scrollbars=0,resizable=0,
width=240,height=120);
qtwin.focus();
}
// >
</script>
You can set height and width to whatever value you need. Note that all the text between "qtwin =" and the following ");" must be on a single line (no carriage return) with no spaces.
Using Javascript to Detect QuickTime
Using JavaScript to detect a plug-in is something of a black art. You need to take into account the users operating system, browser type, and browser version you need to use JavaScript, VBScript and ActiveX objects, and even then it wont always work. The easiest and most reliable way to detect QuickTime is to use QuickTime itself. Still, in some circumstances it is possible to detect a plug-in by using a combination of JavaScript and VBScript. Heres how it works:
- Netscape browsers (all versions, all operating systems) you can use the JavaScript plugins object.
- Internet Explorer (version 5 or later, Mac OS) you can use the JavaScript plugins object.
- Internet Explorer (Windows) you can use VBScript and ActiveX to detect QuickTime 4.1.1 or later
<script language="Javascript">
<! hide from pre-script browsers
var haveqt = false;
// >
</script>
<script language="VBScript">
<! hide from pre-script browsers
On Error Resume Next
Set theObject = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")
On Error goto 0
If IsObject(theObject) Then
If theObject.IsQuickTimeAvailable(0) Then Just check for file
haveqt = true
End If
End If
// >
</script>
<script language="Javascript">
<! hide from pre-script browsers
if (navigator.plugins) {
for (i=0; i < navigator.plugins.length; i++ ) {
if (navigator.plugins[i].name.indexOf("QuickTime") >= 0)
{ haveqt = true; }
}
}
// >
</script>
</head>
<body bgcolor="#ffffff">
<H1>Check for QuickTime</H1>
<script language="Javascript">
<! hide from pre-script browsers
if (haveqt)
{document.write(<embed src="hotfire.mov" width=120 height=51>);}
else
{document.write(You do not seem to have " +
"<a href="http://www.apple.com/quicktime">QuickTime</a>);}
// >
</script>
<noscript>
Your browser doesnt support scripting, so you cant check for QuickTime.
</noscript>




