javascript bookmark 添加书签到 firefox IE opera safari 适于大部分浏览器

Posted by bower on July 27, 2009
cross browser, javascript

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

<script type=”text/javascript”>// <![CDATA[
function addBookmark( o) {
var url = o.href;
var title = o.title;
var isSafari = navigator.userAgent.toLowerCase().indexOf(‘webkit’)!=-1;
if(document.all){ //IE
window.external.AddFavorite(url, title);
} else if(isSafari){
alert(‘please press ctrl + D to bookmark’);//只有safari不能用javascript添加
o.href=”#bookmark”;
}
}
// ]]></script><a title=”bowerpower” onclick=”addBookmark(this);” rel=”sidebar” href=” http://www.bowerpower.cn “>收藏此链接</a>

例子如下

收藏此链接

分享到:人人网开心网腾讯微博新浪微博豆瓣分享腾讯空间百度搜藏腾讯书签

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word