我收到了构建网站的任务,我想知道如何在不使用 JavaScript 或不为 iframe 提供 ID 的情况下在单击链接时更改 iframe? 我也宁愿使用 ID,但是,这是不允许的。
最佳答案
您可以在 iframe 外部使用 html 链接,并将目标设置为 iframe 的名称。
See the w3schools Example Here
<iframe src="demo_iframe.htm" name="iframe_a"></iframe>
<p><a href="http://www.w3schools.com" target="iframe_a">W3Schools.com</a></p>
如果链接位于 iframe 内,您只需在链接上设置 target=_self
即可。
<a href="http://www.w3schools.com" target="_self">W3Schools.com</a></p>
关于html - 我可以在没有js或ID的情况下更改iframe src吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33741303/