zoukankan      html  css  js  c++  java
  • 加入收藏夹、打印、设置首页

    加入收藏夹:

    <!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);
                }
            }
        }
  • 相关阅读:
    EFCore数据库迁移命令
    EF基本操作
    EF执行存储过程
    [vue]element-ui使用
    [vue]vue-router的使用
    [vue]使用webpack打包
    [vue]插槽与自定义事件
    [vue]计算属性
    [vue]axios异步通信
    [vue]组件
  • 原文地址:https://www.cnblogs.com/jingzi111/p/5101863.html
Copyright © 2011-2022 走看看