5

我希望在页面中创建一个链接或按钮来更改 iframe 所在的页面。这将是一个本地页面:

idreesinc.com/iframe.html

你可以看到我已经在这里:

idreesinc.com/research

帮助将不胜感激,因为我多年来一直在寻找答案。谢谢!

4

4 回答 4

19

You can simply make an link with its target to the iframe name as follows:

<iframe name="demo" src="example.php"></iframe>

Your link in the parent will be:

<a href="newpage.html" target="demo">Change Link</a>
于 2015-04-07T20:28:32.733 回答
16
<script>
function setURL(url){
    document.getElementById('iframe').src = url;
}
</script>
<iframe id="iframe" src="idreesinc.com/research.html" />
<input type="button" onclick="setURL('URLHere')" />
于 2012-05-09T22:40:06.063 回答
1

Create a button inside a link with its target pointing to the iframe name:

<iframe name="demo" src="site1.html"></iframe>
<a href="site2.html" target="demo"><button>site2</button></a>
于 2020-08-14T21:26:07.713 回答
0
于 2012-05-09T22:40:50.780 回答