How can I create a link to page and load specific content in iframe on that page

六眼飞鱼酱① 提交于 2019-12-05 02:20:24

问题


On our website we have a page that pulls content from another location in to an iFrame. I would like to know how I can create a link to the parent page and have a specific page load in the iFrame.

So, I'd like to create a link to http://xxx.xxx.com/page and have the iFrame on that page load http://yyy.xxx.com/anotherpage

Thanks in advance!!


回答1:


You should give your iframe element a name attribute and then target that name in your anchor tag.

Like so:

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

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

Fiddle

See the MDN documentation for more info.

Hope it helps!




回答2:


you'd have to add an iframe to http://xxx.xxx.com/page like this:

<iframe src="http://xxx.yyy.com/anotherpage"></iframe>


来源:https://stackoverflow.com/questions/17618314/how-can-i-create-a-link-to-page-and-load-specific-content-in-iframe-on-that-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!