您好,有谁知道javascript clear()是什么意思吗?

我在网上看到document.clear();清空文档的意思,现在浏览器不支持;应改成:
document.write("");
document.close();
于是我这样写了:
<html>
<head>
<script type="text/javascript">
document.write("");
document.close();
</script>
</head>
<body>
<h1>fffff</h1>
</body>
</html>
为什么不能清空啊?刚接触,小菜,高手来帮解决一下啊!

眼眸繁星
浏览 337回答 2
2回答

蝴蝶不菲

javascript没有clear方法,这方法是自定义的方法,看字面意思是清除的意思。

缥缈止盈

这段script脚本没执行吧。你应该写一个方法function clearText(){document.write("");document.close();}然后在<body onload="javascript:clearText();"><h1>ffff</h1></body>示例如下:<html><head><script type="text/javascript">function clearText(){document.write("");document.close();}</script></head><body onload="javascript:clearText();"><h1>fffff</h1></body></html>
打开App,查看更多内容
随时随地看视频慕课网APP