Apache flex 如果未安装Flash,如何重定向到HTML页面?

Apache flex 如果未安装Flash,如何重定向到HTML页面?,apache-flex,redirect,Apache Flex,Redirect,如果用户没有安装Flash,我希望在我的Flex应用程序中重定向到HTML页面。我注意到Flash生成的HTML中有: <div id="flashContent"> <p> To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

如果用户没有安装Flash,我希望在我的Flex应用程序中重定向到HTML页面。我注意到Flash生成的HTML中有:

        <div id="flashContent">
            <p>
                To view this page ensure that Adobe Flash Player version 
                10.0.0 or greater is installed. 
            </p>
            <script type="text/javascript">

                 var pageHost = ((document.location.protocol == "https:") ? "https://" :    "http://"); 
                 document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='" 
                                + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" ); 
            </script> 
        </div>


要查看此页面,请确保Adobe Flash Player版本
已安装10.0.0或更高版本。

var pageHost=((document.location.protocol==“https:”)?“https:/”:“http:/”); 文件。填写(“”);
显示关于没有闪存的一般消息

我知道如果Flash不存在,我可以在那里显示HTML,但如果不需要,我不想加载HTML(安装Flash时的情况),所以我认为最好的方法是在Flash不存在的情况下重定向到HTML页面


如何在Flex中做到这一点?

您将无法在Flex中做到这一点,因为如果用户没有正确的Flash player版本,您的应用程序将无法加载。因此,您最好修改index.template.html文件。您尚未指定所使用的Flex版本,版本4和版本3之间的模板文件可能不同

Flex 3使用以下JS代码来检测用户是否拥有良好的Flashplayer版本:

// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

if ( hasProductInstall && !hasRequestedVersion ) {
//剪

} else if (hasRequestedVersion) {
} else {  // flash is too old or we can't detect the plugin
//剪

} else if (hasRequestedVersion) {
} else {  // flash is too old or we can't detect the plugin
在最后一个地方,您需要插入JS代码以重定向,例如:

window.location.replace('otherpage.html');
您的模板文件应该有类似的内容

更多关于JS重定向的信息-

Flex 4

首先禁用HTML包装下的project properties->Flex编译器中的快速安装警告:这将覆盖您的html模板文件夹,因此您对这些文件的所有修改都将丢失。当你这样做的时候,你应该得到一个确认弹出窗口

然后在文本编辑器中打开html模板/swfobject.js。转到第693行-它应该位于函数embedSWF中的“显示替代内容”下-并对其进行注释和添加,或者将其替换为:

window.location.replace('http://mydomain/noflash.html');
保存文件后,执行干净的生成

这是最直接的方法。还有一种更为优雅的方式,即不修改swfobject.js,而是修改index.template.html,但需要编写更多的代码


请注意Flex编译器下的某些设置将覆盖您的html模板文件夹,从而撤消您对其中文件所做的任何更改

谢谢@bug-a-lot。我尝试了上面的代码,但没有成功!可能是因为我使用的是Flex4?很可能Flex4有不同的HTML模板。我明天会调查的。