Close the browser in the flex Application

Source: Internet
Author: User

You only need to call the global function geturl () to open any website in and before corner 2. In ActionScript 3, the global function geturl () has been canceled and replacedFlash.netFunctions in the packageNavigatetoURL ()The API format is as follows:
Public Function navigatetoURL (request: URLRequest, window: String = NULL): void

If you want to close the browser window in the flex application, you can use navigatetoURL to call Javascript. The following is an example for online search:

Reference

<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
<Mx: SCRIPT>
<! [CDATA [
Private function closeie (): void {
VaR request: URLRequest = new URLRequest ("javascript: window. Close ()");
NavigatetoURL (request, "_ Self ");
}
]>
</MX: SCRIPT>
<Mx: button textalign = "center" label = "close current IE" Click = "closeie ()"/>
</MX: Application>

After testing, you will find that a confirmation message is displayed before the window is closed. If you want to close the window and do not bring up the information window, you can simply change the above Code (change the line for the request variable declaration, pay attention to the black part.

Reference

VaR request: URLRequest = new URLRequest ("javascript:Window. Opener = NULL;Window. Close ()");

It can be simpler, as shown below:

Reference

<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
<Mx: button textalign = "center" label = "close current IE" Click = "navigatetoURL (New URLRequest ('javascript:Window. Opener = NULL;Window. Close () '),' _ Self ') "/>
</MX: Application>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.