简体   繁体   English

使用Flex 4.6在Mozilla Firefox或Google Chrome上关闭浏览器不起作用

[英]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.

相关问题 为什么Cut,Copy,Paste在Mozilla Firefox和Google Chrome浏览器中不起作用? - why Cut,Copy,Paste is not working in Mozilla Firefox and Google Chrome browser? Java代码可在Mozilla Firefox中运行,但不能在Google Chrome中运行 - Javascript code working in Mozilla Firefox but not in Google Chrome 网站滑块在Google Chrome和Mozilla firefox上不起作用 - website slider is not working on Google Chrome and Mozilla firefox getURL(&quot;javascript:window.close();&quot;) 不适用于当前的网络浏览器,如 firefox mozilla 和 google chrome - getURL("javascript:window.close();") not working in current web browser like firefox mozilla and google chrome 如何在Mozilla firefox中关闭浏览器时提醒用户 - How to alert user while closing the browser in Mozilla firefox SVG网格线在缩放时在Google Chrome中模糊,但在Mozilla firefox中工作正常 - SVG Grid lines are Blurred in Google Chrome while zooming but its work fine in Mozilla firefox 在Mozilla firefox和google-chrome中,“评估”不能作为javascript函数名称使用 - “Evaluate” doesn't work as a javascript function name in Mozilla firefox and google-chrome Google登录API在Mozilla Firefox上不起作用 - Google sign in API does not work on Mozilla Firefox 使用JavaScript打开Mozilla Firefox浏览器 - Open Mozilla Firefox Browser using JavaScript 用于关闭浏览器FireFox / chrome / IE的JavaScript / jquery - JavaScript/ jquery for Closing Browser FireFox / chrome / IE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM