我想要做个效果控制iframe的src属性
在界面一种单击按钮后会调用方法,执行我js 函数
left.jsp<input type = button  onClick="actioncome()" value=点击>
js代码
function actioncome(){
document.getElementById("myiframe").src="Myjsp.pis"
}
right.jsp <iframe id="myiframe" height="100%" width="100%" src="right.jsp" border="0" frameborder="0" scrolling="auto"></iframe>我写的代码是这样的,请问错哪里了,怎么解决

解决方案 »

  1.   

    http://blog.csdn.net/theforever/article/details/6126635
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title></title>
    </head>
    <body>
        <input type ="button" onClick="actioncome()" value="点击" />
        <script type="text/javascript">
            function actioncome(){
                document.getElementById("myiframe").src="http://www.google.cn"
            }
            
        </script>
        <iframe id="myiframe" height="100%" width="100%" src="http://www.baidu.com" border="0" frameborder="0" scrolling="auto"></iframe>
    </body>
    </html>
      

  3.   

    通用方法: document.getElementById('iframe的ID').contentWindow.document.getElementById('元素的ID')
      注意要加上contentWindow,往往出现问题都是因为这个容易被忽略,它代表FRAME和IFRAME内部的窗口对象。
    1楼博客这句话正解