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

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

问题描述

我有这个 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>

我想要做的是..当我点击 iframe 页面中的任何链接时..然后我会去它并且页面将加载并且我将从当前页面到 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.

类似于 target="_self" 的东西 - 不像普通的 iframe,它会在浏览器本身没有任何变化的情况下转到此链接.

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

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

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

当我点击 iframe 页面内的Learn HTML"时..然后我会去http://www.w3schools.com/html/default.asp并且我的浏览器 URL 也会更改为它.

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.

所以我只是点击了 iframe 中的一个链接,然后我就去了.

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

有什么想法吗?

推荐答案

是的,您可以使用 target="_parent" 来实现这一目标.

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

"target="_parent" 在父框架中打开链接的文档."

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

示例:

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

<小时>

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

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

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

基本目标:

<base target="_parent" />

window.top.location 在 JavaScript 中:

Or window.top.location in JavaScript:

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

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

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