Parsing Img Tags Javascript Using Innerhtml
Here is the dilemma: I am doing a javascript effect. To do so I am pulling a node and it's children (including images) with .innerHTML. Then trying to parse it via the DOM. When it
Solution 1:
IE automatically capitalizes Tag names (so becomes ) so I used txt.replace(/><\/a>/g, " /></a>").replace(/><\/A>/g, " /></A>")
Thanks to all who helped!
Solution 2:
I'm assuming your getting the "txt" variable by using innerHTML? I tested that in various browsers, and it does indeed strip the ending tag. Perhaps, before sending it to the function loadXMLString, you could add them back using regular expressions?
var re = newRegExp("(<img\b[^>]*)>", "g");
txt = txt.replace(re, "$1 />");
Post a Comment for "Parsing Img Tags Javascript Using Innerhtml"