简体   繁体   English

document.write清除页面的所有控件

[英]document.write clear all controls of page

document.write clear all controls of page HI' when the document.write be run, all controls in the web pages will be clear . document.write在运行document.write时清除HI'页的所有控件,网页中的所有控件都将被清除。 why? 为什么? In asp file 在asp文件中

Use innerHTML of say a div to write. 使用一个div的innerHTML编写。

<div id="iwanttowritemore"></div>

Then in JS: 然后在JS中:

document.getElementById("iwanttowritemore").innerHTML = "i can write without clearing the page"

You can't use document.write after the page has loaded, it'll replace the entire page with the contents of said function. 页面加载后不能使用document.write ,它将用所述函数的内容替换整个页面。 Use something else like innerHTML if you need to insert content after the page loads. 如果您需要在页面加载后插入内容,请使用诸如innerHTML类的东西。 document.write is kinda frowned upon anyways. 无论如何, document.write还是有点皱眉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM