码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-06-23 11:45:13      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

 

<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”后

技术分享

 

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

标签:

原文地址:http://www.cnblogs.com/kaituorensheng/p/4590349.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!