Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    76
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Arrow detecting quicktime - Please help

    Hi guys, i would like a script that detects if quicktime is installed like this one here http://developer.apple.com/internet/...lplugins.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..
    Code:
    <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?
    Last edited by embeebutterly; 10-04-2011 at 04:37 PM. Reason: Resolved

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    To detect if QuickTime is installed, you can use this:
    Code:
    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.

    Use that instead of your external javascript, but for usage use it like:
    Code:
    if (detectQuickTime() == true) {
    actually, you can make it less verbose like:
    Code:
    if (detectQuickTime()) {
    ...since it will return true if QuickTime is installed and false if otherwise.


    Hope that helps.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    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
    Code:
    <script>
    detectQuickTime("http://www.mysite.com/error-install-quicktime.htm", "http://www.mysite.com/player.htm");
    </script>

  • #4
    New Coder
    Join Date
    Jan 2011
    Posts
    76
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Sorry Guys Cant seem to mate either of those two examples work!

  • #5
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Code:
    <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>
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    embeebutterly (10-04-2011)

  • #6
    New Coder
    Join Date
    Jan 2011
    Posts
    76
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rangana View Post
    Code:
    <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!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •