通过Flex-Actionscript在Internet Explorer中更改窗口标题

Mic*_*l K 2 apache-flex internet-explorer actionscript

我正在寻找一种方法来动态设置Internet Explorer中的Flex应用程序的窗口标题.执行此操作的最佳方法是从actionscript调用javascript以通过"ExternalInterface"设置窗口标题.

ExternalInterface.call("eval(window.document.title ='New Title')"); ExternalInterface.call("alert","Hello ExternalInterface");

这在IE以外的浏览器中工作正常,当通过html包装器访问flex应用程序的swf文件时,它甚至可以在IE中工作.

ttp:// localhost:8080/ChangeTitle/ChangeTitle.html

但是,我需要直接从浏览器访问.swf .. ttp:// localhost:8080/ChangeTitle/ChangeTitle.swf

这会导致外部接口调用将窗口标题更改为不起作用,但警报仍会显示.

所以问题是......为什么我不使用html包装器?答案:因为项目是专门设置的,以避免使用html包装器.

这与已知的IE错误有关 - http://bugs.adobe.com/jira/browse/FP-240

如果有人可以建议解决这个问题,我将不胜感激.

谢谢

RIA*_*tar 5

不要使用ExternalInterface; 使用BrowserManager类.您可以先用标题初始化它:

var browser:IBrowserManager = BrowserManager.getInstance();
browser.init("", "my title");
Run Code Online (Sandbox Code Playgroud)

稍后您可以稍后调整标题:

browser.setTitle("my new title");
Run Code Online (Sandbox Code Playgroud)

我有几个应用程序使用它并在IE中完美工作(虽然我还没有测试过IE6).
有关此主题的更多信息:http://help.adobe.com/zh_CN/flex/using/WS2db454920e96a9e51e63e3d11c0bf64e50-7ff4.html