[英]Closing Browser not work on Mozilla Firefox or Google Chrome using Flex 4.6
I am using Flash Builder 4.6, Creating Flex Application. 我正在使用Flash Builder 4.6创建Flex应用程序。 I am trying to close browser using flex 4.6 code.This is work on Internet Explore but not work in Mozilla Firefox or Google Chrome.
我正在尝试使用Flex 4.6代码关闭浏览器。这在Internet Explorer上有效,但在Mozilla Firefox或Google Chrome中不起作用。 My code is here
我的代码在这里
<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
protected function btnClose_clickHandler(event:MouseEvent):void
{
var url:URLRequest = new URLRequest("javascript:window.close()");
navigateToURL(url,"_self");
}
]]>
</fx:Script>
<s:Button id="btnClose" x="44" y="47" label="Close Browser" click="btnClose_clickHandler(event)"/>
Ive found that browsers are inconsistent in interpreting the second parameter of navigateToURL. Ive发现浏览器在解释navigationToURL的第二个参数时不一致。
If your swf is not in an html frame, you can use "_top" instead of "_self" (which does work across browsers): 如果您的swf不在html框架中,则可以使用“ _top”而不是“ _self”(在所有浏览器中都可以使用):
navigateToURL(url,"_top");
Or just leave out the second parameter completely (as the default is the same as targetting "_self"): 或者只是完全省略第二个参数(因为默认值与定位“ _self”相同):
navigateToURL(url);
What you are asking for is not allowed in most browsers, and for good reasons. 出于充分的原因,大多数浏览器都不允许您要求什么。 You would have to exploit bugs or hacks to achieve it...
您必须利用错误或黑客来实现它...
A popular one was to refresh and close it in javascript: 一种流行的方法是用javascript刷新并关闭它:
window.open('', '_self', ''); window.open('','_self',''); window.close();
window.close();
My advice would be, dont do it. 我的建议是,不要这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.