We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 04f1da4 commit 2e69c07Copy full SHA for 2e69c07
1 file changed
client/prism/codeBox.js
@@ -165,11 +165,24 @@ function CodeBox(elem) {
165
166
}
167
168
+ // Evaluates a script in a global context
169
+ function globalEval( code ) {
170
+ var script = document.createElement( "script" );
171
+ script.text = code;
172
+ document.head.appendChild( script ).parentNode.removeChild( script );
173
+ }
174
+
175
function runJS() {
176
- console.log(code);
177
+ //console.log(code);
178
if (isTrusted) {
179
180
+ if (elem.hasAttribute('data-autorun')) {
181
+ // make sure functions from "autorun" go to global scope
182
+ globalEval(code);
183
+ return;
184
185
186
try {
187
/* jshint -W061 */
188
window["eval"].call(window, code);
0 commit comments