Problem with bookmarklet – JavaScript in href inside <a> tag
-
I was blogging about some bookmarkets I like and I was trying to procide links so that my readers could save them too.
I noted a problem with some of the links I provided. At first I thought it only happens with bookmarklets that have an URL insite HREF, as the links get truncated when published. But then I noticed it happens with any bookmarklet that has an URL inside single quotes.
For example:
The bookmarklet from pdfdownload.org is
javascript:void(window.open(‘https://www.pdfdownload.org/web2pdf/Default.aspx?left=0&right=0&top=0&bottom=0&page=0&cURL=’+document.location.href));
And this one from Migre.me, a Brazilian URL shortener:
javascript:void(location.href='https://migre.me/atalho/'+escape(location.href));
Both of them have an URL inside single quotes. When you write the link, the code will look like this:
<a href="javascript:void(location.href='https://migre.me/atalho/'+escape(location.href));">Migre.me</a>
So, it’ll have a javascript code between double quotes with an URL between single quotes in it.
The problem is that when I publish it, the SECOND SINGLE QUOTE is automatically changed by a DOUBLE QUOTE. So, when hovering through the link, I have only:
<a href="javascript:void(location.href='https://migre.me/atalho/
Of course it doesen’t work.
Am I doing something wrong? I didn’t do this bookmarklets myself, just copied them from their websites. Is there any way around this?
Thanks a lot. I’m already VERY tired of googling for this since last night.
- The topic ‘Problem with bookmarklet – JavaScript in href inside <a> tag’ is closed to new replies.