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


    加入收藏夹:

    <!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);
                }
            }
        }
  • 相关阅读:
    几种常用类的学习
    类,接口
    方法
    数组使用
    条件控制与循环
    类型转换,运算符
    Java基本类型
    SVN基本使用
    【转】MySQL的btree索引和hash索引的区别
    常用命令(java、linux)
  • 原文地址:https://www.cnblogs.com/jingzi111/p/5101863.html
Copyright © 2020-2023  润新知