如何在Javascript中弹出警报? [英] How do I pop up an alert in Javascript?

查看:121
本文介绍了如何在Javascript中弹出警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Javascript中弹出提醒?

How do I pop up an alert in Javascript?

我试过提醒HELLO但是没有不行。

有人可以告诉我正确的语法吗?

Can someone tell me the correct syntax?

哦,顺便说一句,我下载了JavaScript来自我最喜欢的网站的exe。

Oh by the way I downloaded the JavaScript exe from my favorite site.

推荐答案

与VBScript不同,Javascript需要围绕函数调用的括号。

Unlike VBScript, Javascript requires parentheses around function calls.

因此,你需要写 alert(你好!);

它也是优先(但不是必须)用分号结束每个语句;

It's also prefereable (but not required) to end every statement with a semicolon ;.

最后,如果你不是已经,你需要把它放在一个脚本块中,如下所示:

Finally, if you aren't already, you need to put it in a script block, like this:

<script type="text/javascript">
    alert("Hello!");
</script>

在回答原始问题的结尾时,没有javascript exe。您可以将javascript放在HTML页面中的脚本标记内,也可以创建一个独立的 .js 文件并双击它(在Windows中)以使用WSH运行它。

In responce to the end of your original question, there is no "javascript exe". You can put javascript inside a script tag in an HTML page, or you can make a standalone .js file and double-click on it (in Windows) to run it using WSH.

这篇关于如何在Javascript中弹出警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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