How to show a popup without a browser

2019-03-30 11:39发布

I need an "alert" type feature to troubleshoot an error. I am not using a browser and using javascript as windows administaration purposes. So is their a way to view a varibales value if I am not using a browser?

7条回答
Evening l夕情丶
2楼-- · 2019-03-30 12:15

Look at HTA files. These file types allow you to run typical HTML/VBScript/JS code without the need for a browser specifically. Just rename your HTML file to an HTA extension and run it. IT will show your "page" and execute any JS necessary. This type of file will give you access to other WScript functions as well like creating Files or accessing AD if required.

查看更多
Summer. ? 凉城
3楼-- · 2019-03-30 12:16

If you want a windows GUI popup, then:

var timeout = 0;
var buttons = 0;  // OK
var icon = 48; // Exclamation

var shell = new ActiveXObject("WScript.Shell");
shell.Popup("text ...", timeout, "window title", buttons + icon);

and run your jscript program with the wscript command.

查看更多
可以哭但决不认输i
4楼-- · 2019-03-30 12:16

On windows, you can use Windows Script Host to execute your javascript. It has a built in ability to do output, using Echo. There are some nuances though, since WSH uses jscript, not javascript, though the languages are similar.

查看更多
爷、活的狠高调
5楼-- · 2019-03-30 12:19

You can create a simple file that will alert text that is passed to it, for example in python. I don't think there is any way to do this in Javascript though without a browser.

查看更多
ら.Afraid
6楼-- · 2019-03-30 12:24

JScript is a scripting language based on the ECMAScript standard.

JScript is implemented as a Windows Script engine. This means that it can be plugged in to any application that supports the Windows Script host, such as Internet Explorer, Active Server Pages, etc. It also means that any application supporting Windows Script can use multiple languages — JScript, VBScript, Perl, and others.

For reasons that I am not sure about, but I believe it to be related to the fact the the DOM is not available outside the browser, the alert function is also not available outside the browser. In order to popup a dialog box to the user in this case you can use the following code:

WScript.Echo('The quick brown fox jumped over the lazy dog');
查看更多
萌系小妹纸
7楼-- · 2019-03-30 12:25

No with javascript. You can, using Visual Basic Script and MsgBox function. No need to install anything.

'In Hello.vbs. Comments starts with '
MsgBox "Hello there"
查看更多
登录 后发表回答