Javascript to check if there is flash player installed and redirect to the neededn page

9.6k views Asked by At

I have this script. This determines if there is a flash player installed in the browser, it redirects the browser to a flash website. if not, then it opens a non-flash website.

The Code is here:

 <SCRIPT LANGUAGE="JavaScript">
    <!-- 
    if ((navigator.appName == "Microsoft Internet Explorer" &&
        navigator.appVersion.indexOf("Mac") == -1 &&   navigator.appVersion.indexOf("3.1") == -1) ||

    (navigator.plugins && navigator.plugins["Shockwave Flash"])|| navigator.plugins["Shockwave Flash 2.0"]){
    window.location='flash/index.html';
}
else {
    window.location='index.html';
}
-->
</SCRIPT>

What i want is to embed this code in the non-flash index page. it should just check if there is no flash then simply go with the current index file that already has been opened, or if there is no flash player, then load the index file from within the flash website.

Currently, when index.html (non-flash) is opened, it goes into loop and keeps on checking for the flash player. Can I modify the window.location='index.html'; statement no to load any file here, just go on with the file already opened.??

2

There are 2 answers

1
Simeon On BEST ANSWER

Just remove the else statement.

To embed Flash content, I generally suggest using SWFObject. Using the SWFObject Generator is pretty straightforward.

Using SWFObject, you can enter both alternative content and Flash content on the same page. But it requires a little bit of refactoring in your case.

0
Chris On

Since using a JavaScript to achieve what you want just moves the problem to another location you should consider using another Method described here:

http://en.allexperts.com/q/Shockwave-Flash-1515/flash-flash.htm

This method is a secure way to determine if the user has flash or not no matter which browser he uses or which version or if he has enables JavaScript or not.