看到这个老问题,ie 下button会被清掉,导致错误。
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
为什么代码“alert(”);”被执行了,而“document.write(’456′);”没被执行?
我觉得qazwsx_feng 的解释有点道理
以下为引用内容:
alert();是window的方法!write是document的方法,
button按下后window.document已经不是最初的document而是提交后的document
而由于window对象仍然是最初的window对象它的方法仍可执行。
下面的代码在ie和firefox的表现也不一样
window.document.write("111111111")
alert(1)
document.write("22222222222222222")
alert(document.body.innerHTML)
document.write("333333333333")
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
有点头昏了,谁有更好的解释
Leave a reply