View Single Post
Join Date: Jun 2006
Posts: 7,581
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 461
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Javascript using regex to fix html tags

 
0
  #2
Dec 24th, 2008
Maybe something like [untested]:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. var reg = /(<span[^/>]+)\/>/gi;
  2. var str = "<span id='d'/><div id='3'>d</div>" +
  3. "<span id='j' style='blah: 10px'/>";
  4. var a = str.replace(reg, "$1><\/span>");
  5. alert(a);

But this would mean looking away from the actual problem; the problem here is that SPAN HTML tags need to have a ending tag. What is xmlParser here? How come xmlParser returns an invalid span tag; can't it be fixed to return proper spans?

And BTW, this isn't a Firefox problem, it is actually doing what it should do. Since SPAN tags need to have content, the /> is ignored and <span id="something" /> is treated as the start of a SPAN tag.

IMO, the solution you are seeking seems more like a hack.
I don't accept change; I don't deserve to live.
Reply With Quote