用按钮控制iframe显示的网页
View Code
1 //有两个按钮分别响应两个事件,用来控制iframe显示的网页。 2 <script type="text/javascript"> 3 function bd(){ 4 var baidu = document.getElementById("i"); 5 baidu.src = "http://www.baidu.com"; 6 } 7 function xl(){ 8 var sina = document.getElementById("i"); 9 sina.src = "http://www.sina.com.cn"; 10 } 11 </script> 12 <style type="text/css"> 13 #i{ 14 width:400px; 15 height:300px; 16 } 17 </style> 18 </head> 19 20 <body> 21 <iframe id = "i" scrolling = "no"> 22 </iframe> 23 <div> 24 <input type = "button" value ="百度" onclick = "bd()"/> 25 <input type = "button" value ="新浪" onclick = "xl()"/> 26 </div> 27 </body>