Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html escaper

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whoops I missed the void(0); which keeps the page from changing location.

Eric
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic