Home  >  Article  >  Web Front-end  >  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):

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
Susan SarandonOriginal
2024-10-26 13:13:29642browse

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>

To redirect the immediate parent iframe:

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

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!

Statement:
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