| Author |
html escaper
|
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 23621
|
|
|
There used to be a link on top of this page that went to a page to escape HTML characters for posting in this forum. Does anyone know if it still exists?
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
I lost the files on that server and I did not have that page backed up. The following should get you most of the way there: javascript:var elem = document.forms[0].message;elem.value = elem.value.replace(/on/gi,"on").replace(/mouse/gi,"mouse").replace(/>/gi,">").replace(/</gi,"<");void(0); Past it into the address bar or turn it into a bookmarklet. Eric [ May 03, 2008: Message edited by: Eric Pascarello ]
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 23621
|
|
I was actually asking because I wanted to link to it for someone in the Struts forum who couldn't post code because it contained HTML. (The window on that passed now, so it's more for next time.) Maybe we could add the JavaScript to the FAQ? I'd do it, but I'd kind of like to understand what's going on: It went to a new page with the escaped values after doing the replace (when I copied it into the address bar.) I know it did the replace since when I used the browser back button, the escaped values were there.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
whoops I missed the void(0); which keeps the page from changing location. Eric
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 23621
|
|
Thanks Eric. It's now in the wiki and linked from the Struts/JavaScript pages. And I learned something. I didn't even know there was a void function, so my fiddling with the JavaScript wouldn't have gotten anywhere.
|
 |
 |
|
|
subject: html escaper
|
|
|