Linked Questions

38 votes
3 answers
72k views

I came up with a hack to escape HTML using jQuery and I'm wondering if anyone sees a problem with it. $('<i></i>').text(TEXT_TO_ESCAPE).html(); The <i> tag is just a dummy as jQuery ...
Michael Mior's user avatar
  • 28.9k
12 votes
9 answers
82k views

Possible Duplicate: Escaping HTML strings with jQuery JavaScript/jQuery HTML Encoding For example, if I wanted to show the user the string x < 3 in HTML I would need to replace the < ...
Dejas's user avatar
  • 3,651
-3 votes
1 answer
8k views

In javascript how it's possible to replace all occurrence of &,<,> in a string I tried this var str="<>&"; str.replace("&","&amp").replace("<","&lt").replace(">...
abhishek's user avatar
0 votes
1 answer
3k views

I wrote following code: function convert(string) { var before = '&'; var after= '&amp;'; var pattern = new RegExp(before, 'g'); return string.replace(pattern,after); } convert("Dolce ...
cedevita's user avatar
-4 votes
3 answers
5k views

I'm trying to print plain html from javascript and can't figured out how to do so. Example: $('#elem').html('This is a normal string'); // --> This is a normal string $('#elem').html('This <b&...
Alexandre Fradette's user avatar
5 votes
3 answers
142 views

In my game, I changed the list of players from canvas to html, due to which a vulnerability appeared that any player can give himself a name into which he can insert js code, for example, <script&...
TopoR's user avatar
  • 75
0 votes
0 answers
143 views

I have a field Value for segmentations as <Value TBD>, which is not getting printed in the HTML table. This is the way I'm trying to populate the value: if($("th[data-field='rating']").get(0)...
Saikat Neogy's user avatar
3551 votes
32 answers
2.0m views

How can I display JSON in an easy-to-read (for human readers) format? I'm looking primarily for indentation and whitespace, with perhaps even colors / font-styles / etc.
Mark's user avatar
  • 70.5k
386 votes
17 answers
448k views

I want to display text to HTML by a JavaScript function. How can I escape HTML special characters in JavaScript? Is there an API?
fernando123's user avatar
  • 3,909
297 votes
18 answers
408k views

The example I see posted all of the time seems like it's suboptimal, because it involves concatenating strings, which seems so not jQuery. It usually looks like this: $.getJSON("/Admin/GetFolderList/"...
Jeff Putz's user avatar
  • 15k
218 votes
18 answers
261k views

Apparently, this is harder to find than I thought it would be. And it even is so simple... Is there a function equivalent to PHP's htmlspecialchars built into JavaScript? I know it's fairly easy to ...
Bart van Heukelom's user avatar
406 votes
6 answers
708k views

Are they the same as XML, perhaps plus the space one (&nbsp;)? I've found some huge lists of HTML escape characters but I don't think they must be escaped. I want to know what needs to be escaped....
Ahmet's user avatar
  • 4,690
156 votes
9 answers
258k views

I have got an array which I am looping through. Every time a condition is true, I want to append a copy of the HTML code below to a container element with some values. Where can I put this HTML to re-...
Patrick Reck's user avatar
  • 11.4k
130 votes
13 answers
193k views

I'm writing a Chrome extension that involves doing a lot of the following job: sanitizing strings that might contain HTML tags, by converting <, > and & to &lt;, &gt; and &amp;, ...
callum's user avatar
  • 38.5k
79 votes
7 answers
220k views

I'm writing the JS for a chat application I'm working on in my free time, and I need to have HTML identifiers that change according to user submitted data. This is usually something conceptually shaky ...
I GIVE TERRIBLE ADVICE's user avatar

15 30 50 per page
1
2 3 4 5
7