views:

416

answers:

4

In internet explorer how do I escape single quotes.

' works for firefox etc but internet explorer doesn't like it.

For instance

<input type="text" value='Single quotes `&apos;` Here' />

works in firefox but not in IE

+2  A: 

As AJM said in a comment, I'd try this:

<input type="text" value='Single quotes &#39; Here' />

Jon Galloway
+3  A: 

&apos; is not valid HTML - it is an XML only sequence. FireFox is simply sharing a little too much code between its html and xml parser. Use the &#39; sequence (the correct html escape for ') as already suggested.

David
+1  A: 

Use &#39;

You can view a list of all the ISO-8859-1 HTML entities (escape codes) here.

Dan Diplo
+2  A: 

You could surround that particular attribute value with double quotes, and put the single quote in directly.

It appears, also, that some versions of Internet Explorer (correctly) don't recognize the &apos; entity in HTML, only in XML, so you may have some luck with &#39;.

John Calsbeek