我实际上在同一个域上有两个网站。比如说
http://www.abc.com/flashsite
&
http://www.abc.com/htmlsite
flashsite包含完全基于flash的网站,而另一个是基于html的没有flash的网站。我想要的是,如果有人访问我的网址 http://www.abc.com ,javascript应该首先检测他的浏览器中是否安装了插件。如果是,那么它应该直接带我到“flashsite”文件夹,如果不是,那么它应该默认加载 html 网站。
提前致谢。
最佳答案
代码“无耻”复制自http://www.adobe.com/support/flash/how/shock/javaplugs/javaplugs05.html
<script type="text/javascript">
<!-- use this comment tag to hide the enclosed code from old browsers.
//Look for a version of Internet Explorer that supports ActiveX (i.e., one that's
//running on a platform other than Mac or Windows 3.1) or a browser that supports
//the plugin property of the navigator object and that has Flash Player 2.0
//installed.
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"]){
//Load a pre-defined HTML page with Flash Player in it into the browser window.
//window.location='flashed.html';
alert ("flash plugin detected");
}
else {
//Load a pre-defined HTML page without Flash Player into the browser window.
//window.location='nonflashed.html';
alert("flash plugin not detected");
}
// Close the comment tag. -->
</script>
关于如果安装了 Flash Player,则重定向到另一个域的 Javascript 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5026471/