如何避免浏览器中的停止脚本错误
我有一个包含 2500 多个锚标记的页面需要处理。现在在 IE 中它抛出停止脚本错误。可以批量做吗?拿 500 个执行它,然后再拿另外 500 个执行它?
这是代码...
ajaxLinks : function(el, flag) {
var links = $(el).find('a');
var notLinkAr=["a[href^=javascript]","#toolbarId ul li>a","#tool_settings .link a",".page-action-links li>a","#tool_settings .label a",".success-map .success-tabs li>a",".success-map .sm_loggedin li>a", ".analyst_cat li>a",".modal",".layer",".newpage",".close",".hideFromPopup",".pagenum",".next",".prev",".delete_src",".tips","#hidr","#backr"];
$(notLinkAr).each(function(index){
var notLinkI=$(notLinkAr[index]);
if($(notLinkI).is("a")){
if($(notLinkI).length>0){
$(notLinkI).each(function(index1){
$(notLinkI[index1]).addClass("dontAjaxify");
});
}
}
});
$(links).each(function(i, obj){
var link = $(obj);
if(!$(obj).hasClass('dontAjaxify')){
link.attr('rel', link.attr('href'));
var rellnk = link.attr('rel');
if(flag=='ajaxified') {
if(/http/.test(rellnk)){
var relurl;
relurl=rellnk.replace((window.location.protocol + "//"+ window.location.hostname),'')
link.attr('rel', relurl);;
}
}
link.bind('click', function(e){}
我正在为页面中的所有锚标记(2500)添加一个类。
I have a page of more than 2500 anchor tag to process. Now in IE it is throwing the stop script error. Is it possible to do as a batch? Taking 500 executing it and then take the another 500 executing it??
This is the code...
ajaxLinks : function(el, flag) {
var links = $(el).find('a');
var notLinkAr=["a[href^=javascript]","#toolbarId ul li>a","#tool_settings .link a",".page-action-links li>a","#tool_settings .label a",".success-map .success-tabs li>a",".success-map .sm_loggedin li>a", ".analyst_cat li>a",".modal",".layer",".newpage",".close",".hideFromPopup",".pagenum",".next",".prev",".delete_src",".tips","#hidr","#backr"];
$(notLinkAr).each(function(index){
var notLinkI=$(notLinkAr[index]);
if($(notLinkI).is("a")){
if($(notLinkI).length>0){
$(notLinkI).each(function(index1){
$(notLinkI[index1]).addClass("dontAjaxify");
});
}
}
});
$(links).each(function(i, obj){
var link = $(obj);
if(!$(obj).hasClass('dontAjaxify')){
link.attr('rel', link.attr('href'));
var rellnk = link.attr('rel');
if(flag=='ajaxified') {
if(/http/.test(rellnk)){
var relurl;
relurl=rellnk.replace((window.location.protocol + "//"+ window.location.hostname),'')
link.attr('rel', relurl);;
}
}
link.bind('click', function(e){}
Iam adding a class for all the anchor tag(which is 2500) in a page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jQuery 的 .slice 可能会帮助你。
http://api.jquery.com/slice/
上面的代码未经测试,但应该可以工作。
jQuery's .slice may help you.
http://api.jquery.com/slice/
The above code is not tested, but should probably work.