您的位置:首页 > Web前端 > JQuery

jquery加入收藏代码

2014-01-23 11:21 453 查看
<html>
<head>
<script type="text/javascript" src="jquery-1.9.1.js"></script>

<script type="text/javascript">
$(function(){
var basePath = $("#basePath").val();
//收藏本站
$("#favorites").click(function () {        //$里面是链接的id
var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL';
if (document.all) {
window.external.addFavorite(basePath, '优一队列');
} else if (window.sidebar) {
window.sidebar.addPanel('优一队列', basePath, "");
} else {    //添加收藏的快捷键
alert('添加失败\n您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~');
}
});

});

</script>
</head>
<body>

<a href="#" id="favorites">收藏本站</a>

<input type="hidden" name="basePath" id="basePath" value="http://www.youyidl.com" />

</body>
</html>


需要jquery-1.9.1.js的支持~! http://files.cnblogs.com/simpledev/jquery-1.9.1.js
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: