Home >Web Front-end >JS Tutorial >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):
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!