<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需要事件触发。

效果

初始

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

点击“click here”后

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

 

相关文章:

  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2021-08-06
猜你喜欢
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
相关资源
相似解决方案