aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes html escaper Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "html escaper" Watch "html escaper" New topic
Author

html escaper

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30294
    
150

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]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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,"&#111;n").replace(/mouse/gi,"m&#111;use").replace(/>/gi,"&gt;").replace(/</gi,"&lt;");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: 30294
    
150

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: 15376
    
    6
whoops I missed the void(0); which keeps the page from changing location.

Eric
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30294
    
150

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html escaper