Javascript performing differently in different browsers

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
SpiderMonkey
Forum Commoner
Posts: 85
Joined: Fri May 05, 2006 4:48 am

Javascript performing differently in different browsers

Post by SpiderMonkey »

Consider the following code:

Code: Select all

 
reg=/<div class=\"dataset\">.+<\/div>/g;
sets=content.match(reg);
 
for (item in sets) {
  name=sets[item].replace("</div>","");
  name=name.replace("<div class=\"dataset\">",""); //this line causes the error
  page+='<tr><th scope="row">'+name+'</th><td>';
  ...
The loop continues, but I have located the error to be here.

In Firefox and Safari, this spits out a list of items in the specific divs as it should, but in IE it first spits out the entire, unmodified page, then the list of items, and then stops executing with an error. Is this a difference in how the browsers handle regular expressions, or a behaviour of the match function?
Post Reply