zoukankan      html  css  js  c++  java
  • 全浏览器收藏网站javascript

     1      function MyFavorite(sURL, sTitle) {
     2                                  
     3     var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd': 'CTRL';
     4     try{
     5         if (document.all) { //IE类浏览器
     6             try {
     7                 window.external.toString(); //360浏览器不支持window.external,无法收藏
     8                 window.alert("国内开发的360浏览器等不支持主动加入收藏。
    您可以尝试通过浏览器菜单栏 或快捷键 ctrl+D 试试。");
     9             }
    10             catch (e){
    11                 try{
    12                     window.external.addFavorite(window.location, document.title);
    13                 }
    14                 catch (e){
    15                     window.external.addToFavoritesBar(window.location, document.title);  //IE8
    16                 }
    17             }
    18         }
    19         else if (window.sidebar) { //firfox等浏览器
    20             window.sidebar.addPanel(document.title, window.location, "");
    21         }
    22         else {
    23             alert('您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~');
    24         }
    25     }
    26     catch (e){
    27         window.alert("因为IE浏览器存在bug,添加收藏失败!
    解决办法:在注册表中查找
     HKEY_CLASSES_ROOT\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32 
    将 C:\WINDOWS\system32\shdocvw.dll 改为 C:\WINDOWS\system32\ieframe.dll ");
    28     }
    29 
    30 
    31                                   }
  • 相关阅读:
    Python day thirteen
    Python day twelve
    Python day eleven
    Python day ten
    Python day nine
    Python day eight
    Python day seven
    Python day six
    Python day five
    Python day four
  • 原文地址:https://www.cnblogs.com/alisande/p/3330626.html
Copyright © 2011-2022 走看看