日期:2014-05-18  浏览次数:20444 次

求 javascript 在ie8 下 加入收藏夹 ,好使的代码 ??
我用的有
external.AddToFavoritesBar(sURL, sTitle, '');  
window.external.addFavorite(sURL, sTitle);
window.sidebar.addPanel(sTitle, sURL, "");

但都不好使 ,请求一个ie8下 js 加入收藏夹,好使的代码·~~~~~~~??

------解决方案--------------------

IE8???就这样就可以啊。。

HTML code


<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