JavaScript 之 日常积累
1. <a>标签"加入收藏",兼容IE,FireFox等
function bookmarksite() {
if (window.sidebar) {
// Mozilla Firefox Bookmark
window.sidebar.addPanel(document.title, window.location.href, '');
}
else if (window.external && ('AddFavorite' in window.external)) {
// IE Favorite
window.external.AddFavorite(location.href, document.title);
} else if (window.opera && window.print) {
// Opera Hotlist
this.title = document.title;
return true;
} else {
// webkit - safari/chrome
alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
}
}
//加入收藏
function bookmarksite(title, url) {
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else
if (window.opera && window.print) { // opera
var elem = document.createElement('a');
elem.setAttribute('href', url);
elem.setAttribute('title', title);
elem.setAttribute('rel', 'sidebar');
elem.click();
}
else
if (document.all)// ie
window.external.AddFavorite(url, title);
}
2、刷新页面避免重新发送
//用下面替换 document.location.reload();
location.href = location.href;
若为cs后台:在执行的方法尾部添加一条重载页面既可。
Response.Redirect(Request.Url.ToString());
JavaScript 之 日常积累的更多相关文章
- javascript 技巧总结积累(正在积累中)
1.文本框焦点问题 onBlur:当失去输入焦点后产生该事件 onFocus:当输入获得焦点后,产生该文件 Onchange:当文字值改变时,产生该事件 Onselect:当文字加亮后,产生该文件 & ...
- 来自平时工作中的javascript知识的积累---持续补充中
① SeaJs和RequireJS最大的区别 解惑:来自豆友 ② javascript中如何判断undefined var exp = undefined; if (exp === undefined ...
- Android 开发日常积累
Android 集合 Android 开源项目分类汇总 扔物线的 HenCoder 高级 Android 教程 hencoder HenCoder:给高级 Android 工程师的进阶手册 Andro ...
- javascript的日常代码
1. 直接输出文字: document.write("<显示的类型>显示文字</类型>"); <script>document.writ ...
- Python 日常积累
包管理 >from ... import ... 的用法和直接import的区别 直接使用import时,如果需要使用到导入模块内的属性和方法,必须使用模块名.属性和模块名.方法的方式进行调用 ...
- 日常积累oracle 有关信息
对于VARCHAR2类型,我们在内存使用和效率上需要做出一个权衡.对于VARCHAR2(长度>=2000)变量,PL/SQL动态分配内存来存放实际值,但对于VARCHAR2(长度<2000 ...
- 日常积累之JSON.stringify和JSON.parse substr
1.substr(start,len) 从字符串中读取内容,第一个参数是读取的首位置,如果为负数,则从末尾倒数计数. 第二个参数是要读取的长度. eg: var str = "silence ...
- javascript之小积累-获取url传参的值
在项目中经常遇到两个页面传值的情况,我采取的方案是通过url后面加参数,也就是get方式传值. 这个方式的优点是:传值.获取很方便. 缺点是:1. 把参数都暴露在浏览器中了,一些敏感信息不建议这样传: ...
- javascript之小积累-匿名函数表达式的最佳实践
在写js的时候,还是经常会用的匿名函数表达式,比如 setTimeout(function() { console.log(110); }, 1000); 上面那个function()就是匿名函数表达 ...
随机推荐
- bzoj 3209 数位DP+欧拉定理
枚举1的个数,统计有那么多1的数的个数 /************************************************************** Problem: 3209 Us ...
- poj 3164
朱刘算法 步骤: 1.计算出每个点边权最小的边的权(如果除根以外有其他的点没有入边,则不存在最小树形图),并记下边的另一个端点(称其为这个点的前趋) 2.沿着每个点向上走,如果在走到根或环上的点之前, ...
- Windows下ftp服务器搭建及配置
Win系统使用ser-u软件进行FTP服务器的搭建下载地址:https://www.serv-u.com/操作步骤如下:1. 点击执行程序进行按照SU-FTP-Server-Windows-v15.1 ...
- phpunit Cannot redeclare class PHPUnit_Runner_Version
- Send a WhatsApp Message programatically -- Tasker WhatsTasker
Here is My code snippet: Uri mUri = Uri.parse("smsto:+9876543210"); Intent mIntent = new I ...
- c#分页工具类,完美实现List分页
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Proje ...
- HTML5 vs FLASH vs SILVERLIGHT
Introduction HTML5 kills off flash; HTML5 kills off Silverlight; HTML5 makes the dinner and does the ...
- C\C++各路高手以及操作系统专家请进来杀死这个进程
通常情况下编写一个程序,能够点击关闭button正常结束程序,也能够使用任务管理器结束任务,还能够使用taskkill等命令杀死进程,实在都不行也能够直接重新启动计算机. 可是,这些方法真的都管用吗? ...
- java继承时候类的运行顺序问题
子类在继承父类后,创建子类对象会首先调用父类的构造函数,先运行父类的构造函数,然后再运行子类的构造函数,例如以下所看到的: class Father{ public Father(){ System. ...
- [翻译] 带有震动效果的 ShakingAlertView
ShakingAlertView 震动效果的AlertView https://github.com/lukestringer90/ShakingAlertView ShakingAlertView ...