0

I'm making a list of links that have bookmarklets inside. The problem is that there are quotes in the bookmarklet that clash with the quotes. Is there a way to fix this, or otherwise is there a different way to do it?

Code:

<a href='javascript:(function() {    var l = document.querySelector("link[rel*='icon']") || document.createElement('link');    l.type = 'image/x-icon';    l.rel = 'shortcut icon';    l.href = 'https://google.com/favicon.ico';    document.getElementsByTagName('head')[0].appendChild(l);    document.title = 'Google';})();'>Code</a>

I tried changing the quote type, but that doesn't work. I want the javascript to be inside the link.

ewphmusic
  • 1
  • 1
  • Escape quotes in quotes in Javascript according to Javascript rules. Encode the entire attribute content according to HTML rules, i.e. quotes become `"`. – deceze Feb 17 '23 at 18:46

0 Answers0