• 添加首页


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>兼容ie,chrome,ff的设为首页和收藏本站js代码 web前端资源网 | www.tonjay.com</title>
    </head>
    <body>
    <script type="text/javascript">
    function AddFavorite(sURL, sTitle) {
    try { //IE
    window.external.addFavorite(sURL, sTitle);
    } catch (e) {
    try { //Firefox
    window.sidebar.addPanel(sTitle, sURL, "");
    } catch (e) {
    try{//Chrome无法自动收藏,用创建快应用程序的捷方式来替代。web前端资源网 www.tonjay.com
    createShortcut();
    } catch(e){
    alert("请按Ctrl+D之后按“确定”完成收藏!");
    }
    }
    }
    }
    function setHomepage(pageURL) {
    if (document.all) {
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage(pageURL);
    }
    else {
    try { //IE
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    } catch (e) {
    try{ //Firefox
    var prefs = Components.classes['@mozilla.org/preferences-service;1']
    .getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage',pageURL);
    } catch(e) {
    alert( "您的浏览器不支持该操作,请使用浏览器菜单手动设置." );
    }
    }
    }
    }
    </script>
    <style>
    p a{ margin:0 20px; text-decoration:none; color:#666;}
    p a:hover{ color:#000;}
    </style>
    <p align="center">
    <a href="javascript:void(0);" title="加入收藏" onclick="setHomepage('http://www.tonjay.com');">设为首页</a>
    <a href="javascript:void(0)" title="加入收藏" onclick="javascript:AddFavorite('http://www.tonjay.com','web前端资源网');">加入收藏</a></p>
    </body>
    </html>

  • 相关阅读:
    TCP通信 -C/S中的Socket与ServerSocket
    打印流 -可将数据写入文件/可改变输出方向
    转换流 -解决输入输出时编码格式不统一的问题
    字节/字符缓冲流
    Properties -IO相关的双列集合类
    IO流 -字符输入输出流,以及异常处理方法
    IO流
    线程间的通信
    o(* ̄︶ ̄*)o
    1
  • 原文地址:https://www.cnblogs.com/zhangshuda/p/8136369.html
Copyright © 2020-2023  润新知