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:当文字加亮后,产生该文件 & ...
随机推荐
- 在 Ubuntu下安装 labelImg (标数据用)
安装 SIP 下载 SIP 并解压 : $ sudo python configure.py $ make $ sudo make install 安装 依赖库 $ sudo apt-get ins ...
- 下载Windows版本的Redis
1.打开官网http://redis.io/点击Download 2.往下拉,找到Windows, 由图片中的文字可以看出Redis项目不正式支持Windows. 但是,Microsoft开放技术小组 ...
- Java并发编程-核心问题(1)
一.常见问题 从小的方面讲, 并发编程最常见的问题就是可见性.原子性和有序性问题. 从大的方面讲, 并发编程最常见的问题就是安全性问题.活跃性问题和性能问题. 下面主要从微观上分析问题. 二.可见性问 ...
- The version of SOS does not match the version of CLR you are debugging; SOS.dll版本不匹配; Dump文件不同环境mscordacwks.dll版本问题
The version of SOS does not match the version of CLR you are debugging 和 PDB symbol for clr.dll not ...
- ruby中nil?, empty? and blank?的选择
In Ruby, you check with nil? if an object is nil: article = nil article.nil? # => true empty? che ...
- Django控制器
配置路由 通过对urls.py的配置将用户请求映射到处理函数. Django的URL字符串匹配实际上基于正则表达式,这允许单条URL可以匹配一类请求.参见Django Book中的示例: from d ...
- npm run build之后生成的dist如何扔到服务器运行(npm run build之后如何本地运行)
运行npm run build之后,会生成一个dist文件夹,里面的目录结构大概是这样的: 生成完的文件我们怎么来运行呢?直接在本地打开inde.html是无法运行的,打包的时候有提示: 构建文件应该 ...
- sql SUM求和
- Code Signal_练习题_isLucky
Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if t ...
- bootstrap学习笔记(表单)
1.基础表单 :对于基础表单,Bootstrap并未对其做太多的定制性效果设计,仅仅对表单内的fieldset.legend.label标签进行了定制. fieldset { min-width: 0 ...