The difference between window.location and window.open ()

Source: Internet
Author: User

"Top.location.href" is the outermost page jump
"Window.location.href", "location.href" is this page jump
"Parent.location.href" is a page jump on the previous level.

The location is a property of the Window object, and all the objects under the page are in the window scope chain (this is the top-level scope), so you can omit window when you use it. The top is a pointer to the top-level window object, and the parent is a pointer to the Window object.

Window.location is a property of the Window object, and Window.Open is a method of the Window object
Window.location is your reference to the URL address object of the current browser window!
Window.Open is a function to open a new window!

window.open () is the address of another website that can be opened on one website
and Window.location () is a Web page that can only be opened on a Web site.

Window.location or window.open How do I specify target?
This is a frequently encountered problem, especially when using frame frames.
Workaround:
Window.location to Top.location can be linked to a specified page at the top
Or
window.open ("Your url", "_top");

<input type= "button" value= "New window opens" onclick= "window.open (' http://www.baidu.com ')" >
<input type= "button" value= "current page open" onclick= "top.location= ' http://www.baidu.com ', ' _top '" >

The difference between window.location and window.open ()

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.