jQuery.globalEval( code )返回: 任意类型
描述: 全局执行一些 JavaScript 代码。
-
版本添加: 1.0.4jQuery.globalEval( code )
-
code类型: 字符串要执行的 JavaScript 代码。
-
-
版本添加: 3.4jQuery.globalEval( code [, options ] )
-
code类型: 字符串要执行的 JavaScript 代码。
-
options类型: PlainObject
-
nonce类型: string传递给执行脚本的 nonce 属性。
-
-
-
版本添加: 3.5jQuery.globalEval( code [, options ] [, doc ] )
-
code类型: 字符串要执行的 JavaScript 代码。
-
options类型: PlainObject
-
nonce类型: string传递给执行脚本的 nonce 属性。
-
-
doc类型: Document代码将在其中求值的文档上下文。
-
此方法的行为与使用正常的 JavaScript eval() 不同,因为它是在全局上下文中执行的(这对于动态加载外部脚本非常重要)。
示例
示例 1
在全局上下文中执行脚本。
|
1
2
3
4
5
|
|
示例 2
在启用了内容安全策略的站点上执行带有 nonce 值的脚本。
|
1
2
3
4
5
6
7
|
|