File tree Expand file tree Collapse file tree 1 file changed +13
-22
lines changed Expand file tree Collapse file tree 1 file changed +13
-22
lines changed Original file line number Diff line number Diff line change 1
1
2
2
< 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 ) ;
9
7
}
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
+ }
25
15
}
26
16
}
17
+
27
18
</ script >
28
19
29
- < a href =# onclick ="javascript:addFavorite2( ) " rel =sidebar > 加入收藏</ a >
20
+ < a href =# onclick ="javascript:AddFavorite( " 测试 ","http://www.baidu.com" )" rel=sidebar > 加入收藏</ a >
You can’t perform that action at this time.
0 commit comments