復制代碼 代碼如下:
//有兩個按鈕分別響應兩個事件,用來控制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>