-
Notifications
You must be signed in to change notification settings - Fork 265
/
Copy pathjQuery.globalEval.xml
63 lines (63 loc) · 1.99 KB
/
jQuery.globalEval.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?xml version="1.0"?>
<entry type="method" name="jQuery.globalEval" return="Anything">
<title>jQuery.globalEval()</title>
<signature>
<added>1.0.4</added>
<argument name="code" type="String">
<desc>The JavaScript code to execute.</desc>
</argument>
</signature>
<signature>
<added>3.4</added>
<argument name="code" type="String">
<desc>The JavaScript code to execute.</desc>
</argument>
<argument name="options" type="PlainObject" optional="true">
<property name="nonce" type="string">
<desc>The nonce attribute passed to the executed script.</desc>
</property>
</argument>
</signature>
<signature>
<added>3.5</added>
<argument name="code" type="String">
<desc>The JavaScript code to execute.</desc>
</argument>
<argument name="options" type="PlainObject" optional="true">
<property name="nonce" type="string">
<desc>The nonce attribute passed to the executed script.</desc>
</property>
</argument>
<argument name="doc" type="Document" optional="true">
<desc>A document in which context the code will be evaluated.</desc>
</argument>
</signature>
<desc>Execute some JavaScript code globally.</desc>
<longdesc>
<p>This method behaves differently from using a normal JavaScript <code>eval()</code> in that it's executed within the global context (which is important for loading external scripts dynamically).</p>
</longdesc>
<example>
<desc>Execute a script in the global context.</desc>
<code><![CDATA[
function test() {
jQuery.globalEval( "var newVar = true;" );
}
test();
// newVar === true
]]></code>
</example>
<example>
<desc>Execute a script with a nonce value on a site with Content Security Policy enabled.</desc>
<code><![CDATA[
function test() {
jQuery.globalEval( "var newVar = true;", {
nonce: "nonce-2726c7f26c"
} );
}
test();
// newVar === true
]]></code>
</example>
<category slug="utilities"/>
<category slug="version/1.0.4"/>
</entry>