Anyone ever seen a RegExp/replace that will make all tags lowercase?
I would use the toLowerCase(), but this makes the tags/attribute/content between tags all lowercase. I just need the tags to be lower case inorder to fix IE's problem of uppercase all tags in a document when using DOM and Ajax HTTPRequests.
Just when you thought IE couldn't get anymore evil.. it just did.
Anyone ever seen a RegExp/replace that will make all tags lowercase?
I would use the toLowerCase(), but this makes the tags/attribute/content between tags all lowercase. I just need the tags to be lower case inorder to fix IE's problem of uppercase all tags in a document when using DOM and Ajax HTTPRequests.
I just threw this together so I don't know how robust it is, but it may be adequate for your needs:
Hey rnd me,
I just tried that RegExp it douse make my tag in my string lowercase but it also lowercase's attributes as well. But my question of the XHTML standard quotations for attributes being preserved is still up in the air.
hmm. sorry about that.
i'm still a little confused though.
are you changing the response from ajax, or does the string originate from something.innerHTML ?
if its from ajax, you likely don't need to fix anything; it should work even with uppercase tags. the dynamic info doesn't need to validate, so it should not matter, though it might in xhtml strict i guess...
__________________ my site (updated 5/13) STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%
loads an external .html files source via AJAX and passes it into my applications edit area called pallet(div box).
Once my pallet(div box) has received my external files source I then pass the source of my pallet into a textarea.
Via DOM the client can now add/remove/edit html elments in my pallet(div box).
once a DOM edit has been preformed my textarea gets updated with the pallets new source (here is where I now do a "scrub" and lowercase the string of html from pallet via innerHTML before my textarea gets updated THANK YOU IE!!).
AJAX/PHP then posts the value of my textarea back out to the file it originally came from..
(Reason for using a middle man textarea is to allow users to eiter use DOM to make edits or edit the source by hand. Kinda important in the overall project.)
so far everything has been working perfect in all browser except IE and yes it still works as it should I am just being very strict of my output being XHTML standard.
<Catches breath lol
So begin able to preserve tag attribute quotes after converting a string of html tags to being lower case is kind of the last part of the puzzle lol.
i see. this is why my editor uses only a textarea and hand-coding, to avoid DOM inconsistencies.
if mr hoo's recomendation doesn't work, a worst case scenario could be to make an array with all valid tag names, and loop though them replacing "<XXX" with "<xxx" and also "XXX>" with "xxx>".
that almost has to work.
you can rip off a tag list from w3schools.
__________________ my site (updated 5/13) STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%