Posted By

optimal on 01/04/09


Tagged

ie innerHTML lists Normalized


Versions (?)

Fix "normalized" (broken) lists in IE (think innerHTML)


 / Published in: JavaScript
 

URL: http://oopstudios.com/

Developed as part of my DCODR experiments...

  1. // Is explorer "normalisating" my closing </li> tags?
  2. fixLists = function (html) {
  3. if (navigator.userAgent.indexOf ("MSIE") != -1) {
  4. // Convert <li> to </li><li>
  5. html = html.replace (/<li(\s+[^>]*)?>/gi, "</li><li$1>");
  6. // Then remove any that double up with the opening tag
  7. html = html.replace (/(<(ul|ol)(\s+[^>]*)?>)\s*<\/li>/gi, "$1");
  8. }
  9. // And relax
  10. return html;
  11. };

Report this snippet  

You need to login to post a comment.