解决innerHTML中的script不能执行的问题

// eval scripts from text (from mootools)
function evalScripts(text){
    var script, scripts;
    scripts = [];
    var regexp = /<script[^>]*>([\s\S]*?)<\/script>/gi;
    while ((script = regexp.exec(text))) scripts.push(script[1]);
    scripts = scripts.join('\n');

    if (scripts) (window.execScript) ? window.execScript(scripts) : window.setTimeout(scripts, 0);
}

你可能感兴趣的:(解决innerHTML中的script不能执行的问题)