簡體   English   中英

net :: ERR_NAME_NOT_RESOLVED在動態腳本加載時

[英]net::ERR_NAME_NOT_RESOLVED on dynamic script load

我試圖在運行時(單擊按鈕時)加載腳本(來自同一來源!),但是由於一個奇怪的原因,我在控制台中收到錯誤:net :: ERR_NAME_NOT_RESOLVED

該示例在此鏈接中: https : //www.crazygao.com/ef4/tst.htm

通過單擊文本區域,將初始化一個調用以加載表單-盡管使用相同的動態腳本加載,但該調用由於某種奇怪的原因而成功。 當單擊“ +”以在組合框中添加項目時,將觸發錯誤-請求的腳本將無法加載。

請注意我的通話方式:

// Call to external function in a script:
_.Run=function(p) {
    if(_.xT(p)=="S") p={f:p}; // If the call is string, it will convert it to function name
    if(!window[p.f]) { // If the function not exists in global scope, need to look for the JS file to request it.
        _.xR("/"+p.x||p.f,function() { _.Run(p); }); // Dynamic loader
    }
    else { window[p.f](p.v); } // Run the function
}

// Short hand for loading script on runtime:
_.xR=function(p,f,a) {
    var r=_.xM("script"); // I am creating new <script> tag
    _.xW(r,"charset","UTF-8"); // I set attribute "charset" to "UTF-8"
    r.src=p; // I set the source
    // "a" is not relevant for here - I cut it off
    document.head.appendChild(r); // I append to document head
}

// Short hand for creating new element and appending it to the DOM
_.xM=function(t,i,r,s,c,u) {
    t=document.createElement(t);
    if(t.nodeName=="IMG") t.ondragstart=function(e) { e.preventDefault(); }
    if(i) t.id=i;
    if(r) _.xI(r).insertBefore(t,u);
    /* Unnecessary data I cut off */
    return t;
}

// Short hand for getting element by ID
_.xI=function(e,c) {
    if(_.xT(e)=="S") e=document.getElementById(e); return (e||c)?e:document.body;
}

// Short hand for getting type of variable
_.xT=function(e) {
    if(e instanceof Array) return "A";
    if(e instanceof ML) return "L";
    if(e instanceof Date) return "D";
    if(e instanceof FF) return "F";
    if(e instanceof _.P) return "P";
    if(e instanceof _.C) return "C";
    if(e instanceof Image) return "I";
    if(typeof e==="number"&&!isNaN(e)) return "N";
    if(typeof e==="string") return "S";
    if(typeof e==="boolean") return "B";
    if(typeof e==="function") return "Q";
    return e?"O":null;
}

// Short hand for setting or removing attribute
_.xW=function(c,n,v,s) {
    return s?_.xW(c,n,_.xW(c,n,"~")?0:v):c[(v?(v=="~"?"get":"set"):"remove")+"Attribute"](n,v);
}

我認為“快捷方式”沒有任何錯誤,因為它們正在處理已加載的其他腳本(可以在示例鏈接中查看)。

在服務器中沒有任何阻塞,因為相同的目錄可以被相同的腳本讀取並成功下載(在示例鏈接中:ML.js成功,Lang.js失敗)

非常感謝您的幫助

是:問題的根本原因似乎不是缺少“ /”,而是重復前面的“ /”導致“ https:////ef4/Lang.js ”->瀏覽器可能將此視為“ https:// ef4 / Lang.js “-因此出錯...

問題解決了:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM