I wrote a javascript bookmarklet which works well. It is rather long and it contains many single and double quotation marks as in the following toy example:
javascript:html="<a href='www.example.com'>example</a>";document.write(html);
Now I have to publish it on a web page, that is, I have to insert the javascript string as the url attribute inside an < a > tag in the html source code of the page, so:
<a href="javascript:...">this is my bookmarklet</a>
but obviously there is a conflict due to repeated double quotation marks. Is there any simple way I can write the bookmarklet javascript code inside an html code?
You can URL encode characters in bookmarklets and the bookmarklet will work.
But also you can try using a bookmarklet "generator" to make it easier and faster
This bookmarklet generator was created in 2012 and still works great today: https://mrcoles.com/bookmarklet/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.