<script type="text/javascript">
function xxx()
{
e=event
document.write(e.screenX)//可以顺利执行
document.write(e.screenY)//如果不再一次声明e=event,这一句就执行不了
}
</script>
</head>
<body onmousedown="xxx()">只有在ie7和ie8,下才会出现这个问题,ie6、谷歌opera都没有问题为什么每次执行完document.write,e好像会被删除,要重新给e声明

解决方案 »

  1.   

    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. In   general,   it   is   not   necessary   to   open   the   document   using   the   document.open   method,   since   the   document.write   method   will   automatically   open   the   file   and   discard   (erase)   the   contents.   However,   after   the   write   is   complete,   you   need   to   close   the   document   by   using   the   document.close   method.   In   some   browsers,   the   results   of   the   write   may   not   be   completely   displayed,   due   to   buffering,   until   the   close   occurs.   
      

  2.   

    英语不行啊,看不明白,是说document.write删除页面所以不行吗,但是为什么重新声明e,又可以了
      

  3.   

    简单点说就是,在页面加载完成之后再使用document.write输出字符串,会清空当前页面的内容,只显示你要输出的字符串。
      

  4.   

    document.write()中文档加载的过程中可以多次输出内容到指定的地方,但是文档加载完毕过后,它只输出一次,并且覆盖掉网页上全部的其他内容。
    楼主可以循环一下document.wirte()就知道了..
      

  5.   


    e="x"
    document.write(e+"<br />")
    document.write(e+"<br />")
    //如果说清除页面,连变量都会删除,那为什么上方的代码可以执行,下方却不行
    e=event
    document.write(e.screenX)
    document.write(e.screenY)document.write(event.screenX)
    document.write(event.screenY)//直接引用event对象也行
      

  6.   

    你其实可以这么写:doucment.write(e.screenX,e,screenY);
    write可以接受多个参数,依次输出!!
      

  7.   

    这个问题见过多次了 不要没事用document.write() 换成alert调不就完了么
    write会重新创建新的文档流