Can I detect whether a browser's Bookmarks toolbar is enabled with JavaScript?

三世轮回 提交于 2019-12-04 04:19:54

问题


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?


回答1:


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).




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!