“网络错误:404 未找到”使用 JavaScript 文件
我从 Firebug 收到以下错误。
"NetworkError: 404 Not Found - http://myip/function%20()%20%7B%20%20%20%20tfObjSort.setThings(this);%20%20%20%20return%20this.sort(tfObjSort.charSorter);%7D/"
我认为是我的 JavaScript 之一造成的。该文件是,
(function(){
tfObjSort={
init:function(){
Array.prototype.objSort=function(){
tfObjSort.setThings(this);
var a=arguments;
var x=tfObjSort;
x.a=[];x.d=[];
for(var i=0;i<a.length;i++){
if(typeof a[i]=="string"){x.a.push(a[i]);x.d.push(1)};
if(a[i]===-1){x.d[x.d.length-1]=-1}
}
return this.sort(tfObjSort.sorter);
};
Array.prototype.strSort=function(){
tfObjSort.setThings(this);
return this.sort(tfObjSort.charSorter)
}
},
sorter:function(x,y){
var a=tfObjSort.a
var d=tfObjSort.d
var r=0
for(var i=0;i<a.length;i++){
if(typeof x+typeof y!="objectobject"){return typeof x=="object"?-1:1};
var m=x[a[i]]; var n=y[a[i]];
var t=typeof m+typeof n;
if(t=="booleanboolean"){m*=-1;n*=-1}
else if(t.split("string").join("").split("number").join("")!=""){continue};
r=m-n;
if(isNaN(r)){r=tfObjSort.charSorter(m,n)};
if(r!=0){return r*d[i]}
}
return r;
},
charSorter:function(x,y){
if(tfObjSort.ignoreCase){x=x.toLowerCase();y=y.toLowerCase()};
var s=tfObjSort.chars;
if(!s){return x>y?1:x<y?-1:0};
x=x.split("");y=y.split("");l=x.length>y.length?y.length:x.length;
var p=0;
for(var i=0;i<l;i++){
p=s.indexOf(x[i])-s.indexOf(y[i]);
if(p!=0){break};
};
if(p==0){p=x.length-y.length};
return p;
},
setThings:function(x){
this.ignoreCase=x.sortIgnoreCase;
var s=x.sortCharOrder;
if(!s){this.chars=false;return true};
if(!s.sort){s=s.split(",")};
var a="";
for(var i=1;i<1024;i++){a+=String.fromCharCode(i)};
for(var i=0;i<s.length;i++){
z=s[i].split("");
var m=z[0]; var n=z[1]; var o="";
if(z[2]=="_"){o=n+m} else {o=m+n};
a=a.split(m).join("").split(n).join(o);
};
this.chars=a;
}
};
tfObjSort.init();
}());
据我所知,上面的脚本没有问题。
有什么问题吗!?
I'm getting the following error from Firebug.
"NetworkError: 404 Not Found - http://myip/function%20()%20%7B%20%20%20%20tfObjSort.setThings(this);%20%20%20%20return%20this.sort(tfObjSort.charSorter);%7D/"
I assume that one of my javascripts caused it. The file is,
(function(){
tfObjSort={
init:function(){
Array.prototype.objSort=function(){
tfObjSort.setThings(this);
var a=arguments;
var x=tfObjSort;
x.a=[];x.d=[];
for(var i=0;i<a.length;i++){
if(typeof a[i]=="string"){x.a.push(a[i]);x.d.push(1)};
if(a[i]===-1){x.d[x.d.length-1]=-1}
}
return this.sort(tfObjSort.sorter);
};
Array.prototype.strSort=function(){
tfObjSort.setThings(this);
return this.sort(tfObjSort.charSorter)
}
},
sorter:function(x,y){
var a=tfObjSort.a
var d=tfObjSort.d
var r=0
for(var i=0;i<a.length;i++){
if(typeof x+typeof y!="objectobject"){return typeof x=="object"?-1:1};
var m=x[a[i]]; var n=y[a[i]];
var t=typeof m+typeof n;
if(t=="booleanboolean"){m*=-1;n*=-1}
else if(t.split("string").join("").split("number").join("")!=""){continue};
r=m-n;
if(isNaN(r)){r=tfObjSort.charSorter(m,n)};
if(r!=0){return r*d[i]}
}
return r;
},
charSorter:function(x,y){
if(tfObjSort.ignoreCase){x=x.toLowerCase();y=y.toLowerCase()};
var s=tfObjSort.chars;
if(!s){return x>y?1:x<y?-1:0};
x=x.split("");y=y.split("");l=x.length>y.length?y.length:x.length;
var p=0;
for(var i=0;i<l;i++){
p=s.indexOf(x[i])-s.indexOf(y[i]);
if(p!=0){break};
};
if(p==0){p=x.length-y.length};
return p;
},
setThings:function(x){
this.ignoreCase=x.sortIgnoreCase;
var s=x.sortCharOrder;
if(!s){this.chars=false;return true};
if(!s.sort){s=s.split(",")};
var a="";
for(var i=1;i<1024;i++){a+=String.fromCharCode(i)};
for(var i=0;i<s.length;i++){
z=s[i].split("");
var m=z[0]; var n=z[1]; var o="";
if(z[2]=="_"){o=n+m} else {o=m+n};
a=a.split(m).join("").split(n).join(o);
};
this.chars=a;
}
};
tfObjSort.init();
}());
As far as I see, there's no problem with the script above.
What's the problem!?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您可能正在将函数体本身写到某个超链接中。单击超链接时会发生这种情况吗?检查并确保您使用的是 href="javascript:myFunction();"并正确绑定您的事件处理程序。
It seems like maybe you're writing out the function body itself into the hyperlink somewhere. Does this happen when you click on a hyperlink? Check to make sure you're using href="javascript:myFunction();" and binding your event handlers correctly.