jquery設爲首頁,加入收藏代碼

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> 
02  
03 //添加到收藏夾 
04 <script type="text/javascript"
05  
06     $(document).ready(function () { 
07  
08     $("#favorites").click(function () {    //$裏面是鏈接的id 
09  
10         var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' 'CTRL'
11  
12         if (document.all) { 
13  
14         window.external.addFavorite('http://www.baidu.com''百度'
15  
16         else if (window.sidebar) { 
17  
18         window.sidebar.addPanel('百度''http://www.baidu.com'""
19  
20         else {    //添加收藏的快捷鍵 
21  
22         alert('添加失敗\n您可以嘗試通過快捷鍵' + ctrl + ' + D 加入到收藏夾~'
23  
24         
25  
26     }) 
27  
28     }); 
29  
30 </script> 
31  
32  
33 //設置主頁 
34  
35 $("#addHomePage").click(function () { 
36  
37         if (document.all) {//設置IE 
38  
39         document.body.style.behavior = 'url(#default#homepage)'
40  
41         document.body.setHomePage(document.URL); 
42  
43         else {//網上可以找到設置火狐主頁的代碼,但是點擊取消的話會有Bug,因此建議手動設置 
44         alert("設置首頁失敗,請手動設置!"); 
45         
46 })
發佈了69 篇原創文章 · 獲贊 13 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章