Aak*_*thy 71 javascript bookmarks cross-browser
是否有任何跨浏览器书签/使用JavaScript添加到收藏夹.
搜索了一些列表但没有一个正在运行.你能建议吗?
Ger*_*der 51
jQuery版本
JavaScript(从我在某人的网站上找到的脚本修改 - 我再也找不到该网站,所以我无法给予该人信用):
$(document).ready(function() {
$("#bookmarkme").click(function() {
if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(location.href,document.title,"");
} else if(window.external) { // IE Favorite
window.external.AddFavorite(location.href,document.title); }
else if(window.opera && window.print) { // Opera Hotlist
this.title=document.title;
return true;
}
});
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<a id="bookmarkme" href="#" rel="sidebar" title="bookmark this page">Bookmark This Page</a>
Run Code Online (Sandbox Code Playgroud)
如果你不从服务器上运行它,IE将显示错误(当它作为一个服务器查看时,它不允许通过JavaScript使用JavaScript书签file://....
如果你需要一个更完整的脚本,你总是可以从这个页面购买一个(不,我不隶属于该网站......大声笑).
小智 9
function bookmark(title, url)
{
if (window.sidebar)
{// Firefox
window.sidebar.addPanel(title, url, '');
}
else if (window.opera && window.print)
{// Opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();//this.title=document.title;
}
else if (document.all)
{// ie
window.external.AddFavorite(url, title);
}
}
Run Code Online (Sandbox Code Playgroud)
我用过它,在IE,FF,Netscape中运行得很好.Chrome,Opera和Safari不支持它!
我在想不.书签/收藏夹应该在用户的控制之下,想象一下,如果您访问过的任何网站只需要一些javascript就可以将自己插入到书签中.
| 归档时间: |
|
| 查看次数: |
169403 次 |
| 最近记录: |