I have made an AJAX call and bringing back some data from the server and then That data would be converted to XML through javascript. Now i am creating various elements like TABLE, TR, TD, Anchor to render that data using createElement method. and also i have to set some Usual and custom attributes to those elements and then render it on page.
Now my problem is when i use element.setAttribute(name, value) in a loop then after rendering 80 rows my IE shows alert that "This script is taking to long to run and should be aborted YES|NO " this kind of warning so can anybody help me where i am wrong and what kind of optimization can be done or there is any alternative for that.
This function is used for setting the attributes.
Expand|Select|Wrap|Line Numbers
- function processTagAttributes(target, attributes){
- if(attributes != null){
- for (i = 0; i<attributes.length; i++){
- var splited = attributes[i].split("|");
- if( splited[0] == 'style'){
- target.style.cssText = splited[1];
- }
- else if( splited[0] == 'class'){
- target.className = splited[1];
- }
- else{
- target.setAttribute( splited[0], splited[1], 0);
- }
- }
- attributes = null;
- }
- }