html - 如何创建指向页面的链接并在该页面的 iframe 中加载特定内容

标签 html iframe hyperlink

在我们的网站上,我们有一个页面可以将内容从另一个位置提取到 iFrame 中。我想知道如何创建指向父页面的链接并在 iFrame 中加载特定页面。

所以,我想创建一个指向 http://xxx.xxx.com/page 的链接并加载该页面上的 iFrame http://yyy.xxx.com/anotherpage

最佳答案

您应该为您的 iframe 元素提供一个名称属性,然后在您的 anchor 标记中定位该名称。

像这样:

<iframe src="iframe.htm" name="iframe_a"></iframe>

<a href="http://www.urltowebsite.com" target="iframe_a">My link</a>

Fiddle

参见 the MDN documentation获取更多信息。

希望对您有所帮助!

关于html - 如何创建指向页面的链接并在该页面的 iframe 中加载特定内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17618314/

相关文章:

javascript - 无法使用 Cheerio 获取 iframe

c# - 如何将 BoundField 转换为 HyperLinkField?

visual-studio-2010 - LNK1000:IMAGE::BuildImage 期间的内部错误

html - 将标题 float 到两个不同的 div

javascript - iframe history.length 查询

javascript - swf播放完毕后有什么办法运行JS?

javascript - 如何阻止来自 iframe 的请求

CSS <a> 标签状态正在大量改变颜色,即点击一个链接会将所有链接更改为 'visited' 颜色——有什么想法吗?

javascript - 如何将一些 HTML 插入到 javascript 中

javascript - 使用 Ajax 搜索 keyup 和文档就绪