解决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);
}

posted @ 2010-09-19 11:50 果果’er 阅读(...) 评论(...) 编辑 收藏