日期:2014-05-18 浏览次数:20444 次
<a href="javascript:window.external.AddFavorite('http://www.dtan.so','Dtan网址导航')">收藏本站 </a>
------解决方案--------------------
加入收藏夹需要用户点击确认,
ie8的实现方法是,如果不是用户点击的,默认是忽略执行的,也不报错的。
不要页面打开使用 js 直接自动运行加入收藏夹的代码。
你可以<input type=button onclick="window.external.AddFavorite('http://xxx','xx')">测试,才能知道是否支持
------解决方案--------------------
文档写的很清楚
Windows Internet Explorer 8 and later. For security reasons, the AddFavorite method must be called as a response to a user-initiated action, such a mouse click. If called from a different context, such as the onload event of the body element, the AddFavorite method fails silently.
http://msdn.microsoft.com/en-us/library/ms535926%28v=vs.85%29.aspx
Windows Internet Explorer 8 and later. For security reasons, the AddToFavoritesBar method must be called as a response to a user-initiated action, such a mouse click. If called from a different context, such as the onload event of the body element, the AddToFavoritesBar method fails silently.
http://msdn.microsoft.com/en-us/library/cc197035%28VS.85%29.aspx