关于window.onload问题 document.writeln后会刷新页面内容,其实已经打印出1111111了,只是load完后被刷掉而已 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建议不要用document.writeln 会改变文档结构你可以用document.body.innerHTML += "<p>2222222222</p>"; 呃,囧啊,那为什么如下代码不会刷掉原来内容啊?document.writeln倒底有什么样的属性啊?我要疯了。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head><body><p>1111111111</p><script type="text/javascript">document.writeln("2222222222");</script></body></html> 同意2楼的 用innerHTML就可以了都不知道原来还有writeln这东西 哪位高手可以说下innerHTML属性与writeln的细节吗?小弟狂晕中。 http://zhidao.baidu.com/question/51696717.htmlhttp://zhidao.baidu.com/question/51696717.html参考一下 做个空DIV往里填innerHtml,或者添加TextNode节点。 我喜欢贴官方说明:You should not use the write or writeln methods on the current document after the document has finished loading unless you first call the open method, which clears the current document's window and erases all variables. document.body.innerHTML += " <p>2222222222 </p>"; 这是很基础的问题啊。1, document.onload 是在DOM树被Browser加载完之后才执行的。2, 在onload 方法里,你调用的是 document 的writeln方法, 它回把你的整个document会被 writeln的参数 代替, 所以你看不见 你先前在页面中的所有内容(111111)3, 当你的script 直接嵌入在document其他位置, 如你所写的地方, Browser会从上往下处理DOM树, 所以第二种情况就会打出1111111,222222来。建议把javascript高级编程 看看 再问一个fullCalendar 本地化的问题 关于jsp的应用 文本框中只能输入数字或带小数点后两位! 如何合并这2个菜单? 怎样获得层的实际宽度? 有关event.srcElement.children的问题 怎样操作cookie?有详细的介绍吗? 按窗口右上角关闭窗口时的又一问题 怎样使新打开的窗口在屏幕上居中,并且只有一个关闭按钮! 一个小问题,但老是不能解决. 关于js表单验证 谁可以教我下要如何做个‘选项卡’啊?
你可以用document.body.innerHTML += "<p>2222222222</p>";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title></head><body>
<p>1111111111</p>
<script type="text/javascript">
document.writeln("2222222222");
</script>
</body>
</html>
都不知道原来还有writeln这东西
参考一下
You should not use the write or writeln methods on the current document after the document has finished loading unless you first call the open method, which clears the current document's window and erases all variables.
这是很基础的问题啊。
1, document.onload 是在DOM树被Browser加载完之后才执行的。
2, 在onload 方法里,你调用的是 document 的writeln方法, 它回把你的整个document会被 writeln的参数 代替, 所以你看不见 你先前在页面中的所有内容(111111)
3, 当你的script 直接嵌入在document其他位置, 如你所写的地方, Browser会从上往下处理DOM树, 所以第二种情况就会打出1111111,222222来。建议把javascript高级编程 看看