...

View Full Version : Resolved detecting quicktime - Please help



embeebutterly
10-04-2011, 12:48 PM
Hi guys, i would like a script that detects if quicktime is installed like this one here http://developer.apple.com/internet/webcontent/examples/detectallplugins.shtml

but i want it to offer the link to quicktime if not installed, and continue to load the player if quicktime is installed.

Im thinking something like this..



<script type="text/javascript"
src="http://developer.apple.com/internet/webcontent/examples/detectallplugins.shtml "></script>
<script>
if (detectQuickTime == true) {
setTimeout('Redirect()',0);
}
else
{
setTimeout('Redirect2()',0);
}

function Redirect()
{
location.href = 'http://www.mysite.com/player.htm';
}


function Redirect2()
{
location.href = 'http://www.mysite.com/error-install-quicktime.htm';
}
</script>


But i cant make it work. Can anyone help?

rangana
10-04-2011, 01:43 PM
To detect if QuickTime is installed, you can use this:


function detectQuickTime () {
var haveqt = false;
if (navigator.plugins) {
for (i=0; i < navigator.plugins.length; i++ )
haveqt = (navigator.plugins[i].name.indexOf("QuickTime")>=0)?true:haveqt;
}
haveqt = ((navigator.appVersion.indexOf("Mac") > 0)&&(navigator.appName.substring(0,9)=="Microsoft")&&(parseInt(navigator.appVersion) < 5))?true:haveqt;

return haveqt; // outputs true if QuickTime is installed
}

...it's a modified version from (Apple) Safari's Dev Library (http://developer.apple.com/library/safari/#documentation/QuickTime/Conceptual/QTScripting_JavaScript/bQTScripting_JavaScri_Document/QuickTimeandJavaScri.html#//apple_ref/doc/uid/TP40001526-CH001-SW1).

Use that instead of your external javascript, but for usage use it like:


if (detectQuickTime() == true) {


actually, you can make it less verbose like:


if (detectQuickTime()) {


...since it will return true if QuickTime is installed and false if otherwise.


Hope that helps.

devnull69
10-04-2011, 01:47 PM
detectQuickTime is a function (and not a variable). This function requires two parameters ... which are two URLS, the first URL is used to redirect to if Quicktime has not been detected and the second is the redirect URL in case Quicktime has been detected.

So replace your code with


<script>
detectQuickTime("http://www.mysite.com/error-install-quicktime.htm", "http://www.mysite.com/player.htm");
</script>

embeebutterly
10-04-2011, 02:10 PM
Sorry Guys Cant seem to mate either of those two examples work!

rangana
10-04-2011, 04:01 PM
<script type="text/javascript">
function detectQuickTime () {
var haveqt = false;
if (navigator.plugins) {
for (i=0; i < navigator.plugins.length; i++ )
haveqt = (navigator.plugins[i].name.indexOf("QuickTime")>=0)?true:haveqt;
}
haveqt = ((navigator.appVersion.indexOf("Mac") > 0)&&(navigator.appName.substring(0,9)=="Microsoft")&&(parseInt(navigator.appVersion) < 5))?true:haveqt;

return haveqt; // outputs true if QuickTime is installed
}

function Redirect() {
location.href = 'http://www.mysite.com/player.htm';
}

function Redirect2() {
location.href = 'http://www.mysite.com/error-install-quicktime.htm';
}

setTimeout((detectQuickTime()?'Redirect()':'Redirect2()'),0);

</script>

embeebutterly
10-04-2011, 04:31 PM
<script type="text/javascript">
function detectQuickTime () {
var haveqt = false;
if (navigator.plugins) {
for (i=0; i < navigator.plugins.length; i++ )
haveqt = (navigator.plugins[i].name.indexOf("QuickTime")>=0)?true:haveqt;
}
haveqt = ((navigator.appVersion.indexOf("Mac") > 0)&&(navigator.appName.substring(0,9)=="Microsoft")&&(parseInt(navigator.appVersion) < 5))?true:haveqt;

return haveqt; // outputs true if QuickTime is installed
}

function Redirect() {
location.href = 'http://www.mysite.com/player.htm';
}

function Redirect2() {
location.href = 'http://www.mysite.com/error-install-quicktime.htm';
}

setTimeout((detectQuickTime()?'Redirect()':'Redirect2()'),0);

</script>


Wonderfull, thanks!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum