toLowerCase rewrite

I don't know enough javascript to fix this issue, but the following line's match statement isn't complex enough.

v=v.replace(/<[^>]*>/g,function(match){return match.toLowerCase()});


In my case it's changing the case of my title tags for some hrefs, but i assume it does it for everything. I haven't bothered seeing how much of a problem this causes, but I guess it could be changing paths to images, files or passed variables in hrefs to lowercase when they don't need to be. Anyway to make it not replace text within double quotes? It's late, but I think that would solve the problem.
asked Apr 3, 2011 by anonymous

9 Answers

0 votes
IE bug it seems.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

 

<body>

<div onclick="javascript:alert(this.innerHTML);">

<ul>

<li>a</li>

<li>b</li>

</ul>

</div>

</body>

</html>



When there's more than one li it only will show the last </li>, firefox shows them all.
answered Apr 3, 2011 by anonymous
0 votes
I'm not sure if that's also what's causing the missing quotes issue. Any IE specific exceptions we can implement? I want to use this editor on a site i'm launching monday, but i don't know how far these issues go. Is it limited to the </li> and rel statement?
answered Apr 3, 2011 by anonymous
0 votes
answered Apr 3, 2011 by anonymous
0 votes
Ok it's the browser. I was using IE8.  In firefox the quotes are still around the rel attribute and the </li> tag is there.
answered Apr 3, 2011 by anonymous
0 votes
Ok one problem solved i believe...

v=v.replace(/<\/?[A-Za-z]+/g,function(match){return match.toLowerCase()});


Now just to figure out what's rearranging the attributes and why my rel lost its quotes...and losing the <li> tag

---------------------------------------------------

Rearranging the attributes of course isn't really an issue, but losing quotes and end tags is.
answered Apr 3, 2011 by anonymous
0 votes
Thanks for reporting! I have updated the script to remove that line and ignore case on the remaining rules. I will circle back when I can and try and accomplish the same thing but for solo tags only.
answered Apr 3, 2011 by anonymous
0 votes
Why does it take my good code and rewrite it? Why capitilize the tags that weren't capitilized to begin with...only to try to lowercase them later? Also it removes the quotes from around the rel tag and leaves off the </li> while rearranging all the attributes in my existing code. I don't understand.

<li><a title="URL - Bryan" href="http://www.url.com/location2.htm?office=bryan" rel=shadowbox;width=500>Bryan</a>
answered Apr 3, 2011 by anonymous
0 votes
Ok one problem solved i believe...

v=v.replace(/<\/?[A-Za-z]+/g,function(match){return match.toLowerCase()});


Now just to figure out what's rearranging the attributes and why my rel lost its quotes...and losing the <li> tag
answered Apr 3, 2011 by anonymous
0 votes
Ok, that's not the only the problem. Switching into code view drives all the code nuts. I'm reading this code in from a database.
Bryan
The editor changes it to the below, lowercasing things it shouldn't, moving attributes around within the tag for no apparent reason and it left off the
Bryan 
answered Apr 3, 2011 by anonymous