加载iframe链接到父窗口? [英] Load iframe links into parent window?

查看:176
本文介绍了加载iframe链接到父窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个iframe代码:

 < iframe src =http://www.example.comborder =0framespacing =0marginheight =0marginwidth =0vspace =0hspace =0scrolling =yeswidth =100%frameborder =0height =100% >< / iframe中> 

我想要做的是......当我点击iframe页面中的任何链接..然后我会去它,页面将加载,我会从当前页面跳出到iframe链接作为新页面。



类似于 target =_ self - 不像正常的iframe,它会在没有任何浏览器本身变化的情况下进入这个链接。


$ b 示例:
iframe src: http://www.w3schools.com



当我点击iframe页面中的学习HTML,然后我会去 http://www.w3schools.com/html /default.asp
,我的浏览器URL也会变成它。



所以我只是点击了iframe中的一个链接,我去了它是。



有什么想法?

解决方案

是的,您可以使用 target =_ parent 来实现这一点。


target =_ parent在父框架中打开链接的文档。 b

示例:

 < ; a target =_ parenthref =http://example.org>点击我!< / a> 






编辑:



如果这样做不起作用,您可以尝试 _top

 < a target =_ tophref =http://example.org>点击我!< / a> 

基准目标

 < base target =_ parent/> 

或JavaScript中的 window.top.location

  window.top.location =http://example.com; 


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?

解决方案

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";

这篇关于加载iframe链接到父窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆