復制代碼 代碼如下:
<html>
<head>
<title>JS加入收藏夾</title>
</head>
<script>
function addfavorite()
{
if (document.all)
{
window.external.addFavorite('http://www.baidu.com','收藏夾');
}
else if (window.sidebar)
{
window.sidebar.addPanel('百度一下', 'http://www.baidu.com', "");
}
}
</script>
<body>
<a href="#" onclick="addfavorite()">加入收藏!</a>
</body>
</html>