zoukankan      html  css  js  c++  java
  • 设为主页加入收藏

     1     //加入收藏
     2     function addFavorite() {
     3         if (document.all) {
     4             try {
     5                 window.external.addFavorite(window.location.href, document.title);
     6             } catch (e) {
     7                 alert("加入收藏失败,请使用Ctrl+D进行添加");
     8             }
     9         } else if (window.sidebar) {
    10             window.sidebar.addPanel(document.title, window.location.href, "");
    11         } else {
    12             alert("加入收藏失败,请使用Ctrl+D进行添加");
    13         }
    14     }
    15 
    16     //设为主页
    17     function setHomepage() {
    18         if (document.all) {
    19             document.body.style.behavior = 'url(#default#homepage)';
    20             document.body.setHomePage(window.location.href);
    21         } else if (window.sidebar) {
    22             if (window.netscape) {
    23                 try {
    24                     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    25                 } catch (e) {
    26                     alert("该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
    27                 }
    28             }
    29             var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage', window.location.href);
    30         } else {
    31             alert('您的浏览器不支持自动自动设置首页, 请使用浏览器菜单手动设置!');
    32         }
    33     }
  • 相关阅读:
    网页的尺寸
    前端大杂烩总结
    vscode 2.0 配置
    关于node 版本的一个奇葩的问题 :HPE_UNEXPECTED_CONTENT_LENGTH error #3103
    ADO.NET 增删改查的基本用法
    面向对象 类库 委托
    三大特性:封装,继承,多态
    面向对象 抽象类 多态
    SQL数据库基础(九)
    SQL数据库基础(八)
  • 原文地址:https://www.cnblogs.com/xuejietong/p/8902247.html
Copyright © 2011-2022 走看看