简体   繁体   English

如何在没有浏览器的情况下显示弹出窗口

[英]How to show a popup without a browser

I need an "alert" type feature to troubleshoot an error. 我需要一个“警报”类型功能来解决错误。 I am not using a browser and using javascript as windows administaration purposes. 我没有使用浏览器并使用javascript作为windows管理目的。 So is their a way to view a varibales value if I am not using a browser? 如果我不使用浏览器,那么他们是一种查看varibales值的方法吗?

JScript is a scripting language based on the ECMAScript standard. JScript是一种基于ECMAScript标准的脚本语言。

JScript is implemented as a Windows Script engine. JScript实现为Windows脚本引擎。 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. 这意味着它可以插入任何支持Windows Script主机的应用程序,例如Internet Explorer,Active Server Pages等。这也意味着任何支持Windows Script的应用程序都可以使用多种语言--JScript,VBScript,Perl和其他。

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. 由于我不确定的原因,但我认为它与浏览器之外的DOM不可用的事实相关,因此在浏览器外部也无法使用警报功能。 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');

If you want a windows GUI popup, then: 如果你想要一个Windows GUI弹出窗口,那么:

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. 并使用wscript命令运行您的jscript程序。

On windows, you can use Windows Script Host to execute your javascript. 在Windows上,您可以使用Windows脚本宿主来执行您的JavaScript。 It has a built in ability to do output, using Echo . 它具有使用Echo进行输出的内置功能。 There are some nuances though, since WSH uses jscript, not javascript, though the languages are similar. 但是有一些细微差别,因为WSH使用jscript而不是javascript,尽管语言类似。

No with javascript. 不用javascript。 You can, using Visual Basic Script and MsgBox function. 您可以使用Visual Basic Sc​​ript和MsgBox函数。 No need to install anything. 无需安装任何东西。

'In Hello.vbs. Comments starts with '
MsgBox "Hello there"

You can create a simple file that will alert text that is passed to it, for example in python. 您可以创建一个简单文件来提醒传递给它的文本,例如在python中。 I don't think there is any way to do this in Javascript though without a browser. 我认为没有任何方法可以在Javascript中执行此操作,但没有浏览器。

Look at HTA files. 看看HTA文件。 These file types allow you to run typical HTML/VBScript/JS code without the need for a browser specifically. 这些文件类型允许您运行典型的HTML / VBScript / JS代码,而无需专门的浏览器。 Just rename your HTML file to an HTA extension and run it. 只需将HTML文件重命名为HTA扩展并运行即可。 IT will show your "page" and execute any JS necessary. IT将显示您的“页面”并执行任何必要的JS。 This type of file will give you access to other WScript functions as well like creating Files or accessing AD if required. 这种类型的文件将允许您访问其他WScript函数,如创建文件或访问AD(如果需要)。

A summary of the differences between WScript.Echo and WshShell.Popup : WScript.EchoWshShell.Popup之间差异的摘要:

  • Windows scripts (vbs, js, wsf etc.) can be run under one of two hosts: cscript.exe (command-line), and wscript.exe (graphical). Windows脚本(vbs,js,wsf等)可以在两个主机之一下运行: cscript.exe (命令行)和wscript.exe (图形)。 Under cscript, WScript.Echo will produce a line of text in the console window. 在cscript下, WScript.Echo将在控制台窗口中生成一行文本。 WshShell.Popup will always produce a message window, even under cscript. WshShell.Popup将始终生成一个消息窗口,即使在cscript下也是如此。
  • WshShell.Popup lets you specify the buttons, title and icon type, like the VB/VBS MessageBox function. WshShell.Popup允许您指定按钮,标题和图标类型,如VB / VBS MessageBox功能。 It also lets you specify how long the message should remain open. 它还允许您指定消息应保持打开的时间长度。
  • WScript.Echo lets you pass multiple string arguments to output, and will print them separated with spaces. WScript.Echo允许您将多个字符串参数传递给输出,并以空格分隔打印它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows浏览器中或浏览器外部显示生成的PDF文件? - How to show a generated PDF file with in the browser or outside the browser in windows? 如何在浏览器中显示可打印的PDF文档? - How to show the printable PDF document with in the browser? 如何在没有浏览器的情况下在 python 中使用 Tor? - How to use Tor without browser in python? 如何在没有 NULL 的情况下显示 mysql 查询? - How show mysql query without NULL? 在命令行中打开Web浏览器弹出窗口 - Open a web browser popup in command line VBA:IE-如何在没有弹出文件上传表单的情况下为文件输入标签分配路径名? - VBA:IE-How to assign pathname to file input tag without popup file upload form? Java-如何在没有任何GUI或命令提示符弹出窗口的情况下完全安静地运行我的应用程序? - Java - how to run my application completely silently without any GUI or Command prompt popup? (Javascript) 如何将焦点返回到 OPENER 窗口(不更改其 URL) - 从其(子)弹出窗口? - How (Javascript) return focus to the OPENER window (without changing its URL) - from its (child) popup? 在另一个应用程序的窗口中显示一个弹出菜单 - Show a popup menu in another application's window 强制浏览器不显示打印对话框 - Force browser not to show print dialog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM