开发者

Replace String Code Fast Effiecient

Last few days left i make a script for string replacement with all of yours help. Now i am testing on my all sites but on some site shows stop script popup error in FF, in chrome Kil Page error it seems my script use lots of browser resource when replacing so i need your professional coding touches that make string replace script more efficient fast optimized here is my code:

function avid_number_setup(){

var avidno = '(800).123.1234';

var match_tollandlocal = avidno.match(/800|822|833|844|855|866|877|888|899/gi);

if(match_tollandlocal != null){

 //alert('TollFree number');

 (function($){

   $('*').each(function(i){

   $('body').html($('body').html().replace(avidno,'<span id="avidtoll">AvidTrak Tracking Number</span>'));       

  })

 })(jQue开发者_高级运维ry)

}

if(match_tollandlocal == null){

 // alert('Local number');

 (function($){

   $('*').each(function(i){

   $('body').html($('body').html().replace(avidno,'<span id="avidlocal">AvidTrak Tracking Number</span>'));       

   })

  })(jQuery)

 }  

} 

avid_number_setup();

Need your helps/tips to make my string replace code more fast and efficient.


This code:

$('*').each(

Does something for every element on the page. This takes a lot of time and is not needed. Remove it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜