Friday, August 24, 2012

HtmlEncoding in Javascript


Often when executing fetchxml in javascript or when creating tables throught javascript, you would face the error because the values are not htmlencoded.


function htmlEncode(value) {
    return $('<div/>').text(value).html();
}
function htmlDecode(value) {
    return $('<div/>').html(value).text();
}


This encodes the default characters that have to be encoded.
For more details:
http://support.microsoft.com/kb/316063

No comments:

Post a Comment