JavaScript 检查是否安装了 Flash 播放器并重定向到所需页面
我有这个脚本。这确定浏览器中是否安装了 Flash 播放器,它将浏览器重定向到 Flash 网站。如果没有,则会打开一个非 Flash 网站。
代码在这里:
<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>
我想要的是将此代码嵌入到非闪存索引页中。它应该只是检查是否没有 Flash,然后简单地使用已打开的当前索引文件,或者如果没有 Flash 播放器,则从 Flash 网站加载索引文件。
目前,当打开index.html(非Flash)时,它会进入循环并继续检查Flash播放器。我可以修改 window.location='index.html';
语句 no 来加载此处的任何文件,只继续使用已打开的文件吗?
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.??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需删除 else 语句即可。
要嵌入 Flash 内容,我通常建议使用 SWFObject。使用 SWFObject Generator 非常简单。
使用 SWFObject,您可以在同一页面上输入替代内容和 Flash 内容。但它需要对你的情况进行一些重构。
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.
由于使用 JavaScript 来实现您想要的只会将问题转移到另一个位置,因此您应该考虑使用此处描述的另一种方法:
http://en.allexperts.com/q/Shockwave-Flash-1515/flash-flash.htm
此方法是确定用户是否拥有闪光灯的安全方法或不,无论他使用哪种浏览器或哪个版本,或者他是否启用了 JavaScript。
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.