How can I use JS to add a bookmark specifically in IE9
After reading another StackOverflow question, I started using this javascript "plugin" across my websites. However recently a client told me that it isn't working in IE9. I use Windows XP so I can't test IE9 but I'm 99% su开发者_StackOverflow社区re he's telling the truth. Any ideas?
The code you suggested (copyrighted by a porn site) tests MSIE 8 and higher and uses window.external.AddToFavoritesBar which was introduced in IE8.
I have now successfully tested your suggested code it on >>THIS PAGE<< in the following browsers - all on windows XP except IE9 which I tested on vanilla default win7 installation (IE9 only runs on Win7 or an upgraded Vista)
- IE9 - bookmarks
- IE8 - bookmarks
- Safari5 - shows ctrl-d
- Chrome10 - shows ctrl-d
- Fx4 - bookmarks in sidebar
- Opera v11 - bookmarks
- Mozilla 1.7 - does not show the link.
So the answer to your question is: The code you want to use should work and does work in a standard installation of windows 7 with IE9 default install.
For the readers of this question, here is something much simpler which will work on all browsers (except, for some weird reason, Chrome), simply do this:
Page bookmark (Please right-click to bookmark): <a title="Title of the bookmark (for Opera)"
href="http://fullyQualifiedUrlToYourSite.com/page.html">Title of the bookmark</a>
or if you insist:
Page bookmark (Please right-click to bookmark):
<a title="Title of the bookmark (for Opera)"
href="http://fullyQualifiedUrlToYourSite.com/page.html"
oncontextmenu="if (navigator.userAgent.indexOf('Chrome')!=-1)
alert('Click ctrl-d to bookmark, as you already know as a Chrome-using techie')"
>Title of the bookmark</a>
精彩评论