// JavaScript Document
// 加入收藏 < a onclick="AddFavorite(window.location,document.title)" >加入收藏< /a>

function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败,请使用Ctrl+D进行添加");
        }
    }
}
//设为首页 < a onclick="SetHome(this,window.location)" > 设为首页 < /a>
function SetHome(obj,vrl){
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        }
                        catch (e) {
                                alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
}

使用
< a  href="#" onclick="SetHome(this,window.location)" > 设为首页 < /a>
< a  href="#" onclick="AddFavorite(window.location,document.title)"> 收藏本站 < /a>

兼容IE,chrome,ff的设为首页、加入收藏及保存到桌面的更多相关文章

  1. 完美兼容IE,chrome,ff的设为首页、加入收藏及保存到桌面js代码

    <script  type="text/javascript"> //设为首页 function SetHome(obj,url){     try{         ...

  2. 设为首页 和 收藏本站js代码 兼容IE,chrome,ff

    设为首页 和 收藏本站js代码 兼容IE,chrome,ff //设为首页 function SetHome(obj,url){ try{ obj.style.behavior='url(#defau ...

  3. 设为首页/加入收藏JS代码

    传统网站常用的设为首页/加入收藏js代码 <a href="javascript:void(0)" onclick="sethome(this,window.loc ...

  4. javascript 设为首页 | 加入收藏夹 JS代码

    我们介绍一个可兼容所有浏览器的加入收藏代码代码,大概原理是这样的我们根据获取用户navigator.userAgent.toLowerCase()信息来判断浏览器,根据浏览器是否支持加入收藏js命令, ...

  5. JS代码实现网站设为首页加入收藏功能

    <script language="javascript"> //加入收藏 function AddFavorite(sURL, sTitle) { try { win ...

  6. js代码 设为首页 加入收藏

    // JavaScript Document // 加入收藏 <a onclick="AddFavorite(window.location,document.title)" ...

  7. JS代码:设为首页 加入收藏

    // JavaScript Document // 加入收藏 <a onclick="AddFavorite(window.location,document.title)" ...

  8. HTML设为首页/加入收藏代码

    (特别注意:要把'这个符号换成无任何输入法状态中输入的'这个符号,否则程序无法运行)   1.文字型:     <a onclick="this.style.behavior='url ...

  9. ASP.NET中怎样将页面设为首页,加入收藏

    1.文字js脚本事件:<span onClick="var strHref=window.location.href;this.style.behavior=’url(#default ...

随机推荐

  1. springboot启动过程(2)-run方法

    1 springApplication的run run方法主要是用于创造spring容器ConfigurableApplicationContext对象. public ConfigurableApp ...

  2. java中一些常用的英语

     abstract (关键字  ) 抽象  ['.bstr.kt]  access vt.访问,存取  ['.kses]'(n.入口,使用权)  algorithm n.算法  ['.lg.rie ...

  3. iOS 打包生成ipa文件(使用终端命令打包)

    1. 打开终端 2.在终端输入cd +空格 把工程文件直接拖到终端,然后回车 3. 在终端输入xcodebuild,回车 然后你可以发现工程文件里多了一个build文件夹 在build文件夹中,有一个 ...

  4. 高性能MySQL笔记-第5章Indexing for High Performance-001B-Tree indexes(B+Tree)

    一. 1.什么是B-Tree indexes? The general idea of a B-Tree is that all the values are stored in order, and ...

  5. hive存储处理器(StorageHandlers)以及hive与hbase整合

    此篇文章基于hive官方英文文档翻译,有些不好理解的地方加入了我个人的理解,官方的英文地址为: 1.https://cwiki.apache.org/confluence/display/Hive/S ...

  6. 数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform 标签: 图像处理MATLAB数字图像处理

    实验要求: Objective: To further understand the well-known algorithm Fast Fourier Transform (FFT) and ver ...

  7. Mat的迭代器使用

    如果你熟悉 C++的 STL 库,那一定了解迭代器(iterator)的使用.迭代器可以方便地遍历所有元素.Mat 也增加了迭代器的支持,以便于矩阵元素的遍历.下面的例程功能跟上一节的例程类似,但是由 ...

  8. Umbraco 中获取一个media item的文件路径 file path

    我们要使用UmbracoHelper, 这里就需要用到我们在之前的blog里面写的UmbracoContext 参看这个blog     https://www.cnblogs.com/wphl-27 ...

  9. fiddler----APP弱网测试

    转自:http://www.51testing.com/html/01/n-3727001.html APP弱网模拟测试 移动端测试区别于PC端测试的一点就是网络的多变性:不同的网络环境和网络制式的差 ...

  10. [译]如何在visual studio中调试Javascript

    本文翻译youtube上的up主kudvenkat的javascript tutorial播放单 源地址在此: https://www.youtube.com/watch?v=PMsVM7rjupU& ...