Ok .. this is a strange one as I have NOT seen this before. I have an application that is strictly a Service ... no browser involved ... and all I want to do is use alert(); for debugging. The only problem is that it causes an Object Expected error even if it is a simple alert("Show me!");
Remember ... this code is not attached to any form or browser. So what am I missing? I thought I could use the alert call at any time in Javascript ... Please folks, help a poor programmer out!
Thank you in advance, Eric
Like praneeth already suggested in his reply, it is a Windows WScript thing, or rather just context in which the script is being run in.
This also works and isn't quite as verbose as what praneeth offered:
WScript.Echo("Hello");
if you are executing this script on a windows machine you can do like this in javascript/Jscript
Var Shell = new ActiveXObject("WScript.Shell"); Shell.Popup("Your Debug message");
The alert() method is one of the JavaScript browser Window object's methods which displays an alert box with a message and an OK button.
The window object represents an open window in a browser. If a document contain frames, the browser creates one window object for the HTML document and one additional window object for each frame.
I believe that in the specified case, the error means that the Window expected object has not been found.
Have you tried window.alert("show me");
?
Since alert() is a Window object method.
如果你没有在浏览器中运行,那么使用console.log
方法可能会更好。再次,如果没有任何关于你正在执行脚本的环境的详细信息,很难告诉你具体做什么。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.