用按钮控制iframe显示的网页实现方法

在iframe中显示的网页已经是一件平凡无奇的事了,不过可能依然有很多的童鞋没不知所措吧,没关系,因为本文的出现将会带你脱离苦海,感性的朋友可以了解下啊,或许对你有所帮助

复制代码 代码如下:


//有两个按钮分别响应两个事件,用来控制iframe显示的网页。
<script type="text/javascript">
function bd(){
var baidu = document.getElementById("i");
baidu.src = "http://www.baidu.com";
}
function xl(){
var sina = document.getElementById("i");
sina.src = "http://www.sina.com.cn";
}
</script>
<style type="text/css">
#i{
width:400px;
height:300px;
}
</style>
</head>

<body>
<iframe id = "i" scrolling = "no">
</iframe>
<div>
<input type = "button" value ="百度" onclick = "bd()"/>
<input type = "button" value ="新浪" onclick = "xl()"/>
</div>
</body>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wddzgg.html