不可能吧
你把onUnload换成onbeforeunload呢
2者区别 一个是关闭前执行 一个关闭时执行

解决方案 »

  1.   

    不知道是什么问题,我刚写的这个获取焦点的也不行,鼠标放在输入框上的时候不会清除“请输入信息”这句话,但是show()却可以执行,这个是怎么回事啊?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript">
    function clear() {
    document.hello1.hi.value="";
    }
    function show() {
    window.alert("你输入的值是: " + document.hello1.hi.value);
    }
    </script>
    </head><body>
    <form name="hello1">
    <input type="text" name="hi" value="请输入信息" onfocus="clear()" onblur="show()" />
    </form>
    </body>
    </html>
      

  2.   


    我用IE,和傲游测试都可以啊,你有的什么浏览器?FF?
      

  3.   

    更改方法的名字clear为其他的就可以了。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>无标题文档 </title> 
    <script language="javascript"> 
    function clearText() { 
    document.hello1.hi.value=""; 

    function show() { 
    window.alert("你输入的值是: " + document.hello1.hi.value); 

    </script> 
    </head> <body> 
    <form name="hello1"> 
    <input type="text" name="hi" value="请输入信息" onfocus="clearText()" onblur="show()" /> 
    </form> 
    </body> 
    </html>
      

  4.   

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    变更为
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    这样试试。
    如果OK的话,说明和你的系统环境,
    保存文件的字符集设定有关系。
    如果字符集不正确的话,
    在解析文件的时候会产生错误,
    从而导致javascript角本失效。