document.write与document.getElementById.innterHTML的区别

 

<html>
<head>
    <meta charset="utf-8">
    <script>
        var tmp = "<iframe src='http://www.cnblogs.com/kaituorensheng/'></iframe>";
        document.write(tmp);
        function getValue()
        {
            document.getElementById("show").innerHTML = tmp;
        }
    </script>
</head>

<body>
<div id = "show" onclick="getValue()">click here</div>
</body>
</html>

document.write在页面导入时加载,document.getElementById.innterHTML需要事件触发。

效果

初始

点击“click here”后

 

posted @ 2015-06-23 10:20  jihite  阅读(1447)  评论(0编辑  收藏  举报