如何将单个父 html 中的不同子 html 与第二个子 html 链接起来?
首先,我是网页编程的新手,我似乎没有找到类似的问题来解决我试图弄清楚的情况。也许我没有使用正确的术语...
我有一个父 html 文件(House.html),基本上显示了两个 iframe(“房间”和“信息”),请参见下文。
House.html<br>
-iframe "room"<br>
-iframe "info"
iframe "room"<br>
-Room.html<br>
-->link "link_A"<br>
-->link "link_B"<br>
iframe "info"<br>
-A.html (some text)<br>
-B.html (some text)<br>
在“房间”iframe 中,我正在加载 Room.html,其中包含多个链接(link_A 和 link_B)。单击链接 (link_A) 应该将“info”iframe 更改为显示 A.html。再次单击 link_B 应该将“info”iframe 更改为显示 B.html。所有 html 页面都在同一个域中。
我了解如何将子级链接到父级,但我试图弄清楚如何在父级 html 页面内的特定 iframe 中从第三个 html 页面显示不同的 html 页面。
谁能指出我的答案吗?我是否需要在 House.html 中使用 if() 函数以及 link_A 或 link_B 中的目标值?
First, I am a new at webpage programming and I didn't seem to find a similar question to address the situation I am trying to figure out. Maybe I wasn't using the right terminology...
I have a parent html file (House.html) with essentially two iframes displayed ("room" and "info"), see below.
House.html<br>
-iframe "room"<br>
-iframe "info"
iframe "room"<br>
-Room.html<br>
-->link "link_A"<br>
-->link "link_B"<br>
iframe "info"<br>
-A.html (some text)<br>
-B.html (some text)<br>
Within the "room" iframe I am loading Room.html where there are multiple links contained (link_A and link_B). Clicking a link (link_A) is supposed to change "info" iframe to show A.html. Again, clicking link_B is supposed to change "info" iframe to show B.html. All html pages are on the same domain.
I understand how to link a child to a parent, but I am trying to figure out how to display different html pages in a specific iframe within a parent html page from a third html page.
Can anyone point me to an answer? Would I need to use an if() function in House.html and a target value from link_A or link_B?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 http://webdesign.about.com/ od/iframes/qt/target-links-iframes-and-frames.htm
对于您的具体示例,它看起来像:
From http://webdesign.about.com/od/iframes/qt/target-links-iframes-and-frames.htm
For your specific example, it would look something like:
您可以使用 JavaScript 更改第二个 iframe 的 src 属性。您可以使用 jQuery 来做到这一点 - 例如将此代码放入 iframe1(未经测试)。
请注意,父页面和框架需要来自相同的域和子域(由于单源策略)。如果不是这种情况,您可能需要重新加载整个页面,方法是将
target="_top"
放入 iframe 内的链接中,并更改服务器端的 src。You could use JavaScript to change the src attribute of the second iframe. You can do that with jQuery - e.g. put this code into iframe1 (untested).
Note that the parent page and the frames need to come from the same domain and subdomain (due to the single origin policy). If that's not the case, you would probably need to reload the whole page, by putting
target="_top"
in the link inside the iframe, and changing the src on the server side.