JavaScript jumps out of the IFRAME frame

Source: Internet
Author: User
Tags button type

First, Window.top

The top property returns the topmost ancestor window.

This property returns a read-only reference to a top-level window. If the window itself is a top-level window, the top property holds a reference to the window itself. If the window is a frame, then the top property references the top-level window that contains the frame.

Second, window.self

The Self property returns a read-only reference to the window itself. Equivalent to the Window property.

Third, window.location

The Window.location (MDN) object is used to obtain the address (URL) of the current page and redirect the browser to a new page.

3.1 Example
window.location = ' http://www.mazey.net/'; The site will jump to the following URL
3.2 Properties
    • Location.hostname returns the domain name of the web host
    • Location.pathname returns the path and file name of the current page
    • Location.port returns the port of the web host (80 or 443)
    • Location.protocol returns the Web protocol used (HTTP///https://)
Iv. examples of IFRAME

V. Summary

If you want the page to jump out of the IFRAME and add the following code.

if (window.top!== window.self) {//If the window itself is not equal to the top-level window    window.top.location.href = window.self.location.href;// Top-level window jumps to its own window}

JavaScript jumps out of the IFRAME frame

JavaScript jumps out of the IFRAME frame

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.