Is it possible to drag a bookmarklet from an email? Gmail doesn’t convert the raw javascript into a draggable link and will not attach javascript to image links. I tried several workarounds.
I tried dragging a link then tried to redirect the header location with php. Putting JS in the header redirect is illegal and doesn’t work. I also tried to run eval after clicking the link. This works but it’s running eval against the redirected page rather then the page that it is currently sitting at like bookmarklets should function. I suspect anything involving a redirect will not work for this reason.
But is there anything really clever to try?
Advertisement
Answer
Answer: No.
To arrive at that answer you just have to consider carefully what you are trying to do.
Naturally Google doesn’t want you to put javascript code into emails. That would be a HUGE security hole that hackers and spammers would exploit instantly.
Can you use some clever redirect solution? No. When you drag a link, you are creating a bookmarklet with content equal to exactly what is contained in that links HREF. It is exactly as if you copy pasted the value. So a redirect will have no effect until after the bookmarklet is clicked by the user. Of course a browser will not let you redirect “http”” to “javascript:”. First of all, this would again be a huge security hole. But even more simply, “javascript” is not a real protocol. “Javascript”, “mailto”, “callto”, “about”, and others are often referred to as pseudo-protocols. Notably they are always followed by “:” without “//”. Compare them to real protocols like “http”, “https”, and “ftp” which have standard port numbers associated with them and which always are always followed by “://”. You can’t redirect any real protocol to any pseudo-protocol.