jquery设为首页,加入收藏代码
2014-04-12 14:51
351 查看
<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您可以尝试通过快捷键' + ' ) |
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 | }) |
相关文章推荐
- 加入收藏和设为首页JQuery代码
- c# 设为首页和加入收藏代码收藏
- 设为首页/加入收藏代码
- 设为首页与加入收藏代码
- 设为首页加入收藏代码_兼容各浏览器ie系列Firefox
- 设置主页_加入收藏JQuery代码
- 加入收藏 设为首页js代码
- HTML设为首页/加入收藏代码
- 加入收藏与设为首页代码
- 设为首页/加入收藏代码_兼容各浏览器ie系列 Firefox/360 部分不兼容 请自己尝试
- 设置主页_加入收藏JQuery代码
- 设为首页/加入收藏代码
- 兼容firefox火狐、IE6/IE7/IE8加入收藏,设为首页代码
- 设为首页 加入收藏 关闭当前窗口 的代码
- 设为首页+加入收藏兼容性代码+添加桌面快捷方式
- 设为首页代码和加入收藏代码(兼容各种浏览器)
- 设为首页和加入收藏代码
- 加入收藏 设为首页代码收藏本页的代码和收藏本站的代码设为首页代码
- 网站设为首页和加入收藏JavaScript代码
- 一个可以兼容IE FF的加为首页与加入收藏实现代码