I have a bookmarklet, and my users are consistently clicking it instead of dragging it to their bookmarks bar first. I'd like to add an animation which would run in response to a click on the bookmarklet, say "Drag me to your bookmarks bar!" and show a nifty arrow pointing at the bar.
But that only makes sense if the browser's bookmarks bar is actually visible. Can I detect whether the bookmarks bar is visible using JavaScript?
For security reasons (among others), no - this is not possible with JavaScript.
Even if a browser chose to make this information accessible to the client, it would not be a standard implementation (supported across multiple browsers).
Put a div inside the link that holds a message when the user clicks on it use CSS to show the message. #bookmarklet:active #message{display:block;}
You will need some javascript to return false on the click event.
来源:https://stackoverflow.com/questions/6902695/can-i-detect-whether-a-browsers-bookmarks-toolbar-is-enabled-with-javascript