Skip to content

Commit 38fb6ac

Browse files
authored
Update index.html
1 parent 7078e00 commit 38fb6ac

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

index.html

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11

22
<script>
3-
function addFavorite2() {
4-
var url = window.location || 'http://www.w3cschool.cn';
5-
var title = document.title;
6-
var ua = navigator.userAgent.toLowerCase();
7-
if (ua.indexOf("360se") > -1) {
8-
alert("由于360浏览器功能限制,请按 Ctrl+D 手动收藏!");
3+
//收藏本站
4+
function AddFavorite(title, url) {
5+
try {
6+
window.external.addFavorite(url, title);
97
}
10-
else if (ua.indexOf("msie 8") > -1) {
11-
window.external.AddToFavoritesBar(url, title); //IE8
12-
}
13-
else if (document.all) {
14-
try{
15-
window.external.addFavorite(url, title);
16-
}catch(e){
17-
alert('您的浏览器不支持,请按 Ctrl+D 手动收藏!');
18-
}
19-
}
20-
else if (window.sidebar) {
21-
window.sidebar.addPanel(title, url, "");
22-
}
23-
else {
24-
alert('您的浏览器不支持,请按 Ctrl+D 手动收藏!');
8+
catch (e) {
9+
try {
10+
window.sidebar.addPanel(title, url, "");
11+
}
12+
catch (e) {
13+
alert("抱歉,您所使用的浏览器无法完成此操作。\n\n加入收藏失败,请使用Ctrl+D进行添加");
14+
}
2515
}
2616
}
17+
2718
</script>
2819

29-
<a href=# onclick="javascript:addFavorite2()" rel=sidebar>加入收藏</a>
20+
<a href=# onclick="javascript:AddFavorite("测试","http://www.baidu.com")" rel=sidebar>加入收藏</a>

0 commit comments

Comments
 (0)