JSFiddle - React, Tailwind, and code Playground
HTML
<div id="mydiv"></div>
JavaScript
function newGlobalEval( data ) {
if ( data && rnotwhite.test( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
try{
window[ "eval" ].call( window, data );
}
catch (e){
jQuery.error("eval() failed in jQuery.globalEval() for input: " + data);
}
} )( data );
}
}
rnotwhite = /\S/;
var working = "alert('this works');";
var notWorking = "alert(‘this does not’)";
newGlobalEval(working);
newGlobalEval(notWorking);