Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was reluctant to add this answer, because all the others are good and will be more useful to most people - by answering the underlying question: "How to escape in Javascript inside HTML attributes" - this won't answer that.</p> <p>Some will consider the following a workaround, others will look at it as <em>the only proper solution</em>™.</p> <p>Get rid of the typewriter apostrophe - although typewriters are cool and fashionable in all their retro grandeur, we can do better than that and go even older: Back to the proper, one-size-fits-one, typographic apostrophe (AKA "the curly apostrophe").</p> <p>As a side effect, this will also fix the escaping problem:</p> <pre><code>onclick="sharemusic('Say It Ain’t So', 'Weezer');" </code></pre> <p>The typographers will be happy, and the browser will be happy. Well, as long as you're using UTF-8 like you should - or some other encoding that includes the typographic apostrophe. Unicode: U+2019, entity: <code>&amp;#8217;</code> or <code>&amp;rsquo;</code> (yes, it shares its codepoint with the right single quotation mark - but it's still the "proper" apostrophe).</p> <p>As mentioned in the comments, there are various libraries and CMS/blog plugins that help dealing with conversion to proper typographic symbols (and other typographic niceties). See <a href="http://wordpress.org/plugins/wp-typography/" rel="noreferrer">wp-Typography</a>, <a href="http://daringfireball.net/projects/smartypants/" rel="noreferrer">smartypants</a> (which was, I think, the first implementation of something like this - developed by John Gruber, the original author of Markdown), <a href="https://code.google.com/p/typogrify/" rel="noreferrer">typogrify</a> etc.</p> <p>I'm not sure what, if any, more recent alternatives there are, since I long ago made my own (non-public, I must admit) C# implementation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload