Home > Web Front-end > JS Tutorial > body text

Here are a couple of question titles that fit the provided content: Option 1 (More technical): * How to Redirect the Parent Window from an Iframe using JavaScript? Option 2 (More conversational):

Susan Sarandon
Release: 2024-10-26 13:13:29
Original
641 people have browsed it

Here are a couple of question titles that fit the provided content:

Option 1 (More technical):

* How to Redirect the Parent Window from an Iframe using JavaScript?

Option 2 (More conversational):

* Want to Redirect the Parent Window from an Iframe? He

Redirecting the Parent Window from an iframe

Question:

How can I utilize JavaScript to redirect a parent window from within an iframe? The objective is to redirect the parent window to a new URL when a hyperlink within the iframe is clicked.

Answer:

To redirect the top-level parent iframe:

<code class="javascript">window.top.location.href = "http://www.example.com";</code>
Copy after login

To redirect the immediate parent iframe:

<code class="javascript">window.parent.location.href = "http://www.example.com";</code>
Copy after login

The above is the detailed content of Here are a couple of question titles that fit the provided content: Option 1 (More technical): * How to Redirect the Parent Window from an Iframe using JavaScript? Option 2 (More conversational):. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!