views:

152

answers:

3

I'm trying to store html object tags for video players in a datastore. This data will be serialized and passed back to client javascript where it will be transformed and displayed in the browser to show the video. I need to be able to htmlDecode the data so that it is evaluated properly in the browser.

Any ideas how to accomplish this in javascript?

A: 

Grab your HTML code and run through one of the methods described in this article (I had good results with encodeURI). When ready to use - run it through the compatible decode method

DroidIn.net
I'll give it a try and let you know.
tcoalson
A: 

One of my co-workers suggested the following solution:

http://www.strictly-software.com/htmlencode

This is a set of javascript libraries to encode and decode html.

tcoalson
A: 

Why not use the following method?

HttpUtility.HtmlEncode(...)

And then on the JavaScript side, use the following.

unescape(theEncodedHtml)
DarkWingCoder