• 加入收藏夹、打印、设置首页


    加入收藏夹:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body>
    <script>
    function addFav(){
    if(document.all){
    window.external.addFavorite('http://127.0.0.1/111111/video.html','XXX');
    console.log( 'fvgdsfrg');
    }else if(window.sidebar){
    window.sidebar.addPanel('XXX', 'http://127.0.0.1/111111/video.html','');
    }
    }

    </script>
    <a href="http://127.0.0.1/111111/video.html" title="XXXX" rel="sidebar" onclick="addFav();">加入收藏</a></div>
    <div style="border: 2px solid red; 80px;" onclick="addBookmark('dfsafasdfsa','http://127.0.0.1/111111/video.html')">加入收藏</div>
    </body>
    <script type="text/javascript">
    function addBookmark(title, url) {

    if (window.sidebar) {
    window.sidebar.addPanel(title, url, "");
    }
    else if (document.all) {
    window.external.AddFavorite(url, title);
    }
    else if (window.opera && window.print) {
    window.alert('dfsa');
    return true;
    }

    }
    </script>
    </html>

    打印:

    <script>
        function printpage() {    window.print()    }
    </script>
    <input type="button" value="Print this page" onclick="printpage()">

    设置首页:

     function SetHome(obj, vrl) {
            try {
                obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
                NavClickStat(1);
            }
            catch (e) {
                if (window.netscape) {
                    try {
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                    }
                    catch (e) {
                        alert("抱歉!您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[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);
                }
            }
        }
  • 相关阅读:
    golang-cron定时任务
    卡特兰数
    树的直径
    虚拟机之Hyper-V
    tag of loj
    wx.requestSubscribeMessage无法弹窗,显示20001报错?
    nginx日志切割
    小程序首次加载过慢以及点击微信授权不弹出授权框的问题
    外网访问小程序显示网络错误问题以及总是走wx.request里面的fail回调问题
    http转https以及ssl证书配置以及安装
  • 原文地址:https://www.cnblogs.com/jingzi111/p/5101863.html
Copyright © 2020-2023  润新知