window.open Tips for sharing

Source: Internet
Author: User

Today we talk about window.open again because I found a little bit more fun, the details of which we will explain later. Talk to window.open, have to explain his use method, there are two main forms:
    • window.open () does not have any parameters, this way you can open a page with a new tab
    • window.open (URL, name, pars), with parameters to open the window in the current page
The detailed use method, before has had the introduction, if wants to understand, may click here. Now that you know how to use it, here are a few special properties and methods (all of which are the same domain pages):
    1. window.open () open window or New tab returns window object
    2. In a new window you can also take a Window object to the parent window (which performs the window.open environment) by Window.opner
    3. Window.close () method to close the window
    4. Window.onunload and Window.onbeforeunload events, monitoring window shutdown condition
After learning how to use the above method, we introduce a clever way to use it. A total of two pages: the first page (window.open.html) is the function of a new window, the second page (window.close.html) for the new open window of the request return information, you can in the first page, listen to the new open window request data. Here are two pages: the window.open.html page reads as follows:
<! Doctype>Window.close.html page content is as follows:
<! Doctype>

Through the above described in this way can be resolved, micro-blog and other third-party login without refreshing the parent page to know the return status of the demand. It is also a good way to resolve cross-domain requests (security does not know how). Test small example share such a small trick today ~

window.open Tips for sharing

Related Article

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.