代码如下:
var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'Ctrl';
if (document.all) {
window.external.addFavorite("http://www.baidu.com", "百度");
}
else if (window.sidebar) {
window.sidebar.addPanel("baidu", "http://www.baidu.com", "百度");
}
else {
alert('添加失败,请用Ctrl+D进行添加');
}