最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.??

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.??

Share Improve this question asked Mar 10, 2011 at 7:59 themajiksthemajiks 4141 gold badge8 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

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.

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./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.

发布评论

评论列表(0)

  1. 暂无评论