"警报"运行www.jshint.com时未定义 [英] "alert" is not defined when running www.jshint.com

查看:97
本文介绍了"警报"运行www.jshint.com时未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过简单地添加 var alert; 来解决这个问题但是,这是我应该做些什么才能让讨厌的错误消息消失?这是修复。以下是 www.jshint.com 上的失败。

I fixed this by simply adding var alert; However, is this what I should be doing to get the pesky error message to go away? Here is the fix. Here is the fail on www.jshint.com.

我试图从它抛出的错误中吸取教训......不一定让它们消失。

I'm trying to learn from the error it throws..not necessarily make them go away.

(function () {

"use strict";

var alert;  //  added this in to fix

function initialize_page()
  {
  alert ("hi");
  }

addEventListener('load', initialize_page);

})();


推荐答案

这个文档说明了以下浏览器选项:

This documentation says the following about the browser option:

此选项定义了现代浏览器公开的全局变量:从优秀的文档和导航器到HTML5 FileReader以及浏览器世界中的其他新开发。
注意:此选项不会公开警报或控制台等变量。有关详细信息,请参阅选项devel。

以及关于 devel 选项的以下内容:

and the following about the devel option:

此选项定义通常用于记录穷人调试的全局变量:控制台,警报等。通常最好不要将它们运送到生产中,因为例如,旧版Internet Explorer中的console.log中断。

您已启用浏览器开发已停用。您可以使用jshint原始页面上Assume下的复选框控制这些。我还建议注意文档中的警告; - )

You have browser enabled and devel disabled. You can control these with checkboxes under "Assume" on the jshint original page. I also recommend heeding the warning in the documentation ;-)

这篇关于"警报"运行www.jshint.com时未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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