setTimeout方法里面的方法如果有参数怎么办
<!DOCTYPE HTML> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>setTimeout</title> <script type="text/javascript"> var delayTime; function showAlertAfter(waitingTime, message){ delayTime = window.setTimeout('alert(message)', waitingTime); } </script> </head> <body> <input type="button" value="clickme" onclick="showAlertAfter(5000,'Hello world')"/> </body> </html>
上面的代码,运行会没有反应,因为window.setTimeout('alert(message)', waitingTime);这一行不行,因为message是传进来的参数,但是要怎么改才能让它显示传进来的message呢