Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load iframe links into parent window?

Tags:

html

iframe

I have this iframe code:

<iframe src="http://www.example.com" border="0" framespacing="0" marginheight="0" marginwidth="0" vspace="0" hspace="0" scrolling="yes" width="100%" frameborder="0" height="100%"></iframe> 

What i'm trying to do is..when i click any link in iframe page..then i will go to it and the page will load and i will getout from the current page to the iframe link as a new page.

Something like target="_self" - not like the normal iframe which will go to this link without any changes in browser itself.

Example : iframe src : http://www.w3schools.com

When i click "Learn HTML" inside the iframe page..then i will go to http://www.w3schools.com/html/default.asp and my browser URL will change to it too.

So i just clicked a link inside the iframe and i go to it.

Any ideas?

like image 370
user2203703 Avatar asked Mar 29 '13 23:03

user2203703


People also ask

How do I open an iframe external link in parent window?

To force a single link from iframe to open in the parent window: add target="_PARENT" within that links anchor tag. To force ALL links from iframe to open in the parent window: add the base tag with target="_PARENT" in the head section of the iframe html page.

Can iframe get URL of parent?

Yes, accessing parent page's URL is not allowed if the iframe and the main page are not in the same (sub)domain. However, if you just need the URL of the main page (i.e. the browser URL), you can try this: var url = (window. location !=

How do I open an iframe window in separate windows?

You can do it with jquery and window. open method. JS : var iframe = $("#iframe"); var newWindow = window.


1 Answers

Yes, you can use target="_parent" to achieve this.

"target="_parent" opens the linked document in the parent frame."

Example:

<a target="_parent" href="http://example.org">Click me!</a> 

Edit:

If that's not working, you can try _top:

<a target="_top" href="http://example.org">Click me!</a> 

Or base target:

<base target="_parent" /> 

Or window.top.location in JavaScript:

window.top.location = "http://example.com"; 
like image 142
dsgriffin Avatar answered Sep 20 '22 19:09

dsgriffin