根据不同的按钮点击打开不同的iframe [英] Opening different iframe depending on different button click

查看:95
本文介绍了根据不同的按钮点击打开不同的iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过将iframe src分配给一个变量来打开不同的iframe窗口,
当页面最初加载时应该只显示页面上的两个按钮,当我点击按钮时,iframe应该加载取决于哪个按钮被按下,我试着做这样的事情来创建按钮和创建iframe,但它不工作

 < ;按钮id =b1>按钮1< /按钮> 
< button id =b2>按钮2< /按钮>
< iframe scrolling =nosrc =whatnext>
< / iframe>
< script>
var b1 = document.getElementById('b1'),b2 = document.getElementById('b2');
var x =Hello!;
函数showX(){
var whatnext;
if b1.onclick == true
whatnext =http://community.sitepoint.com/style =border:0px none; height:1555px; margin-left:-116px; margin-顶部:-25px;宽度:930px;
elseif b2.onclick = true
whatnext =http://community.sitepoint.com/style =border:0px none; height:555px; margin-left:-116px; margin-top :-25px; width:330px;
}
< / script>
,另一项试用是
< button id =b1>按钮1< /按钮>
< button id =b2>按钮2< /按钮>