setTimeout在Windows脚本(jscript)中不起作用 [英] setTimeout not working in windows script (jscript)

查看:64
本文介绍了setTimeout在Windows脚本(jscript)中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在程序中运行以下代码

  setTimeout("alert('moo')",1000); 

我收到以下错误

 错误:预期对象编码:800A138F来源:Microsoft JScript运行时错误 

为什么?我在调用错误的函数吗?我想做的是延迟执行后续功能.

解决方案

听起来您正在基于非浏览器的脚本(Windows Script Host或类似脚本)中使用 setTimeout .你不能那样做.但是,您可以使用 WScript.Sleep 暂时挂起脚本,以达到类似的效果.另外, alert 不是WSH函数;它不是WSH函数.您可能需要 WScript.Echo .有关 MSDN上的WSH参考的详细信息..>

When I try to run the following code in my program

setTimeout("alert('moo')", 1000);

I get the following error

Error: Object expected
Code: 800A138F
Source: Microsoft JScript runtime error

Why? Am I calling the wrong function? What I want to do is delay the execution of the subsequent function.

解决方案

It sounds like you're using setTimeout in a non-browser-based script (Windows Script Host or similar). You can't do that. You can, however, use WScript.Sleep to suspend your script briefly, with which you can achieve a similar effect. Also, alert is not a WSH function; you may want WScript.Echo. More on the WSH reference on MSDN.

这篇关于setTimeout在Windows脚本(jscript)中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆