Firefox disable-output-escaping workaround in Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MarkAJAXfan
    • Sep 2008
    • 1

    Firefox disable-output-escaping workaround in Javascript

    Try something like this in your Javascript XSLT routine:

    Code:
    if (navigator.userAgent.indexOf("Firefox") != -1) {
      // fixes most Firefox disable-output-escaping problems:
      document.getElementById(strcontainer).style.visibility = "hidden";
      document.getElementById(strcontainer).appendChild(xslNode);
    
      var nodetext = document.getElementById(strcontainer).innerHTML;
      if (nodetext.indexOf("XML Parsing Error:") == -1) {
    // (note: remove space from first replace char set:)
        nodetext = nodetext.replace(/& amp;/gi, "&");
        nodetext = nodetext.replace(/& lt;/gi, "<");
        nodetext = nodetext.replace(/& gt;/gi, ">");
    
        aja_fill(strcontainer, nodetext);
      }
      else {
       if (pbshowAlertMsgs) {
          // note, try/catch needed
          throw new aja_alertMsg(pbXSLLibHeader, "Error parsing document");
        }
      }
      document.getElementById(strcontainer).style.visibility = "visible";
      nodetext = null;
    }
    else {
      document.getElementById(strcontainer).appendChild(xslNode);
    }
    If needed, you can get the rest of the source for the above segment here:


    or from my post on Bugzilla about this workaround:


    It's all free. Hope this helps those using Firefox.
    Mark
    Last edited by Nepomuk; Sep 12 '08, 08:23 AM. Reason: Added [URL] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    I've moved this to the Editor's Corner so that it can be improved. There's no background information to the problem and an explanation is missing. Once it's been improved, it can be moved back.

    Comment

    Working...