Can I use javascript to add a bookmark that is not an http url?

I have this bookmarklet i.e. it doesn't start with "http:" but with "javascript:". No problem with that, it works correctly.
The problem comes when I want to deploy this to users. I would like to present them with a link that they will simply click to add to their favorites. No matter what methods I use (examples found on the web, or jQuery with jFav), I get a javascript rejection error when the link is clicked, although it works fine when the bookmark link is classic "http".
I believe there is some security in browsers, but is there a way to avoid this?

+2


a source to share


2 answers


This is really a security measure. If a user can be tricked into bookmarking and running a javascript: url, this is pretty much global cross-site scripting.



What you can do is show the user a javascript: link and ask them to bookmark it with a right click or drag and drop to bookmarks. You must also write the link so that it can be copied and bookmarked manually, as some browsers will not display the right click link for a JavaScript link, and others may not display the bookmark bar.

+1


a source


You can ask your users to drag the bookmarklet to bookmarks or toolbar.



+1


a source







All Articles