<html>
<head>
<title></title>
</head>
<body>
<input type="button" onclick="window.setTimeout('var aa="ww";alert(aa)', 1, 'javascript')"
value="dd"></input>
</body>
</html>
上面定义aa是有错误的,请问该如何写才是正确的。
谢谢各位大哥帮忙!

解决方案 »

  1.   

    <html>
    <head>
    <title></title>
    </head>
    <body>
    <input type="button" onclick="var aa='ww'; window.setTimeout(alert(aa), 1, 'javascript')" value="dd">
    <p>
    </body>
    </html>
      

  2.   

    onclick="window.setTimeout('var aa=\"ww\";alert(aa)', 1, 'javascript')"
      

  3.   

    顶。.关于这些代码太多而且有逻辑的 
    应该写在function 中
    那就不需要理会转义字符了
    function cTmpCodeOnload( type)
    {  
    alert(type)
    setTimeout("cTmpCodeOnload("+type+")",5000) 
    }