zoukankan      html  css  js  c++  java
  • ajax请求html页面js不执行

    evalScripts(text){
            let script
            , regexp = /<script(?:s+src=('|")([w.-/]+?)1)?s*>s*([sS]*?)s*</script>/gi
            , head = document.querySelectorAll('head')[0]
            , createScript = function(src,callback){
                let node = document.createElement('script');
                node.type = 'text/javascript';
                node.onload = node.onreadystatechange = function() {
                    if(!/*@cc_on!@*/0 || this.readyState === 'loaded' || this.readyState === 'complete') {
                        this.onload = this.onreadystatechange = null; 
                        this.parentNode.removeChild(this);
                        typeof callback == 'function' && callback()
                    }
                }
                node.src = src;
                return node;
            }
            ,serializeScript = function(){
                script = regexp.exec(text);
                if(!script){return}
                if(script[2]){
                    let node = createScript(script[2],function(){
                        serializeScript(text)
                    })
                    head.appendChild(node)
                }else{
                    window.execScript ? execScript(script[3]) : eval(script[3])
                    serializeScript(text)
                }
            }
            serializeScript();
        }
  • 相关阅读:
    5js
    4js
    3js
    2js
    1js
    7css
    6css
    5css
    Django高级项目实战-开发企业级问答网站,学Django就这了
    Java日志第27天 2020.8.1
  • 原文地址:https://www.cnblogs.com/littleboyck/p/14000094.html
Copyright © 2011-2022 走看看