简单 javascript 跨域iframe 操作

页面A

 <iframe id="ifram1" src="HtmlPage1.html">

    </iframe>


页面b

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <input id="val" value="" />
    <input type="button" value="设置高度" onclick="seth()" />
    <script type="text/javascript">
        
        function seth() {
            var val = document.getElementById("val").value;
            top.window.document.getElementById("ifram1").style.height =val+"px";
        }</script>
</body>
</html>

 

posted @ 2013-11-21 10:23  若隐若现  阅读(329)  评论(0编辑  收藏  举报