Javascript---add to favorite | Set Homepage
<!-- 设为首页 -->
<li><a href="javascript:setHome(this,window.location)">
<span class="glyphicon glyphicon-home"></span> <b>设为首页</b></a>
</li>
<!-- 加入收藏 -->
<li><a href="javascript:addFavorite()">
<span class="glyphicon glyphicon-heart"></span> <b>加入收藏</b></a>
</li> <script type="text/javascript">
function addFavorite() {
var url = window.location;
var title = document.title;
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("msie 8") > -1) {
external.AddToFavoritesBar(url, title, '');//IE8
} else {
try {
window.external.addFavorite(url, title);
} catch (e) {
try {
window.sidebar.addPanel(title, url, "");//firefox
} 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);
}
}
} </script> --------------------- 本文来自 QC班长 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/qq_35624642/article/details/76020134?utm_source=copy
Javascript---add to favorite | Set Homepage的更多相关文章
- [Javascript] Add a browser build to an npm module
In this lesson, we're going to use webpack to create a UMD (Universal Module Definition) build of ou ...
- javascript 技巧总结积累(正在积累中)
1.文本框焦点问题 onBlur:当失去输入焦点后产生该事件 onFocus:当输入获得焦点后,产生该文件 Onchange:当文字值改变时,产生该事件 Onselect:当文字加亮后,产生该文件 & ...
- 231个javascript特效分享
1.文本框焦点问题onBlur:当失去输入焦点后产生该事件onFocus:当输入获得焦点后,产生该文件Onchange:当文字值改变时,产生该事件Onselect:当文字加亮后,产生该文件 <i ...
- .net 开源 JavaScript 解析引擎
1. Javascript .NET 地址为:http://javascriptdotnet.codeplex.com/ 使用方法: Quick Start This section provides ...
- custom event in javascript and jquery
javascript: // add a eventListener document.addEventListener("abc", function(){alert('this ...
- PowerShell实现基于SharePoint的网站HomePage Auto-Configure Solution
Home Page Web Parts Auto-Configuration PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell写的一个自动化升级工具,此为三部自动化工具的 ...
- 介绍(javascript调试)
Chrome developer tool Chrome浏览器得益于其优秀的V8解释器,javascript执行速度和内存占有率表现非常优秀.对于html+css+javascript前台技术的学习或 ...
- JS技巧
2016-08-09 200多个js技巧代码(Down) word下载 200多个js技巧代码 目录 1.文本框焦点问题... 6 2.网页按钮的特殊颜色... 6 3.鼠标移入移出时颜色变化... ...
- 数据表格 - DataGrid - 列表显示
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding=& ...
- 200多个js技巧代码
1.文本框焦点问题 onBlur:当失去输入焦点后产生该事件 onFocus:当输入获得焦点后,产生该文件 Onchange:当文字值改变时,产生该事件 Onselect:当文字加亮后,产生该文件 & ...
随机推荐
- Chapter 3 Phenomenon——4
My truck seemed to have no problem with the black ice that covered the roads. 看起来我的卡车在结冰的路面上面行驶没什么问题 ...
- ibatis Dynamic总结(ibatis使用安全的拼接语句,动态查询)
ibatis中使用安全的拼接语句,动态查询,ibatis比JDBC的优势之一,安全高效 说明文字在注释中 一.引入 一个小例子 <select id="selectAllProduc ...
- Linux的用户(组),权限,文件精妙的三角关系,和强大的帮助系统
在linux中一切都是文件(文件夹和硬件外设是特殊的文件),如果有可能尽量使用文本文件.文本文件是人和机器能理解的文件,也成为人和机器进行 交流的最好途径.由于所有的配置文件都是文本,所以你只需要一个 ...
- For update带来的思考
For update or not 起源 之所以想写这个专题,是因为最近在做一个抢占任务的实现.假设数据库很多个任务,在抢占发生之前任务的状态都是FREE.现在假设同时有一堆抢占线程开始工作,抢占 ...
- css3的overflow-anchor
overflow-anchor属性使我们能够选择退出滚动锚定,这是一个浏览器特性,旨在允许内容在用户当前的DOM位置上加载,而不需要在内容完全加载后更改用户的位置. 为何要有这个属性? 滚动锚定是一种 ...
- 【手记】解决启动SQL Server Management Studio 17时报Cannot find one or more components...的问题
刚装好SSMS 17.1准备体验,弹出: 一番搜索,普遍办法都是安装VS2015独立shell.删除某个注册表项什么的,没用,首先这个shell我是装了的,然后也没有那个注册表项.我自己尝试过重装sh ...
- 简单的node爬虫练手,循环中的异步转同步
简单的node爬虫练手,循环中的异步转同步 转载:https://blog.csdn.net/qq_24504525/article/details/77856989 看到网上一些基于node做的爬虫 ...
- Microsoft .NET Pet Shop 4: Migrating an ASP.NET 1.1 Application to 2.0
249 out of 297 rated this helpful - Rate this topic Gregory Leake Microsoft Corporation Alan Le, Ale ...
- Java中反射和Unsafe破坏单例设计模式
有如下单例模式设计代码: class Singleton { private String info = "HELLO SHIT"; private static Singleto ...
- when coding in a fresh system
I have designed a component of a web system with my workmate. In detail, I am just a coder instead o ...