Skip to content

Instantly share code, notes, and snippets.

@chenwery
chenwery / iframeclick.js
Created February 20, 2014 06:21
javascript:监听页面中iframe被点击
var IframeOnClick = {
resolution : 200,
iframes : [],
interval : null,
Iframe : function() {
this.element = arguments[0];
this.cb = arguments[1];
this.hasTracked = false;
},
track: function(element, cb) {
@chenwery
chenwery / IE version
Last active August 29, 2015 13:56
IE version
检测IE浏览器的版本
@chenwery
chenwery / ajaxfileupload.js
Created February 28, 2014 13:43
ajax file upload
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
if(window.ActiveXObject)
@chenwery
chenwery / query-url.js
Created March 4, 2014 12:53
query-url.js
var qUrl = (function() {
var q = window.location.search;
q = q ? q.split('?')[1].split('&') : [];
var query = {};
jQuery(q).each(function(i) {
var t = q[i].split('=');
query[t[0]] = t[1]
});
return query;
})();
@chenwery
chenwery / syntaxhighlighter-usage.html
Last active August 29, 2015 13:57
syntaxhighlighter
<link rel="stylesheet" type="text/css" href="./syntaxhighlighter/styles/shCoreDefault.css">
<script src="./syntaxhighlighter/scripts/shCore.js"></script>
<script src="./syntaxhighlighter/scripts/shBrushJScript.js"></script>
<script src="./syntaxhighlighter/scripts/shBrushXml.js"></script>
<script src="./syntaxhighlighter/scripts/shBrushCss.js"></script>
<script>SyntaxHighlighter.all();</script>
@chenwery
chenwery / browser.js
Created April 22, 2014 06:53
JS判断移动端访问设备并解析对应CSS
// 判断是否为移动端运行环境
// wukong.name 20130716
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
if(window.location.href.indexOf("?mobile")&lt;0){
try{
@chenwery
chenwery / mysql-simple-config.sh
Last active August 29, 2015 14:01
mysql-simple-config
#install
yum install mysql-server
#auto start on rebooting
chkconfig mysqld on
#start
service mysqld start
(service mysqld stop)
(service mysqld restart)
@chenwery
chenwery / callback.js
Last active August 29, 2015 14:01
跨域解决方法
//parse and organize all QS parameters in a more comfortable way
var params = {};
if (location.search.length > 1) {
var i, arr = location.search.substr(1).split("&");
for (i = 0; i < arr.length; i++) {
arr[i] = arr[i].split("=");
params[arr[i][0]] = unescape(arr[i][1]);
}
}
@chenwery
chenwery / throttle-AND-debounce.js
Last active August 29, 2015 14:09
throttle AND debounce
var throttle = function (fn,delay, immediate, debounce) {
var curr = +new Date(),//当前事件
last_call = 0,
last_exec = 0,
timer = null,
diff, //时间差
context,//上下文
args,
exec = function () {
last_exec = curr;
也就是说 Vary 字段用于列出一个响应字段列表,告诉缓存服务器遇到同一个 URL 对应着不同版本文档的情况时,如何缓存和筛选合适的版本。