How to force link from iframe to be opened in the parent window?

chkdk
chkdk
10 Points
5 Posts

I am using iframe to show different widget page. I need to open all links of the widget pages to the parent window.

Views: 8155
Total Answered: 3
Total Marked As Answer: 0
Posted On: 26-Jun-2017 06:02

Share:   fb twitter linkedin
Answers
edx
edx
52 Points
16 Posts
     

I found the good solution was to use the base tag. Add the following to the head of the page in the iframe:

<base target="_parent">

This will load all links (anchor links) on the page in the parent window. If you want your links to load in a new window, use:

<base target="_blank">

This tag is fully supported in all browsers.

Posted On: 29-Jun-2017 02:00
Jak
Jak
Member
352 Points
151 Posts
     

If you want to a particular link to open parent window use following

<a target="_parent" href="https://www.niceonecode.com">link</a>
Posted On: 29-Jun-2017 02:03
chkdk
chkdk
10 Points
5 Posts
     

With javascript, I found this:

window.parent.location.href= "https://www.google.com";
Posted On: 29-Jun-2017 02:05
banner

Blog

Active User (2)

 Log In to Chat