Skip to content

Instantly share code, notes, and snippets.

View binnng's full-sized avatar
🎯
Focusing

binnng binnng

🎯
Focusing
View GitHub Profile
@binnng
binnng / 0_reuse_code.js
Created February 26, 2014 13:31
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@binnng
binnng / gist:8098272
Created December 23, 2013 14:43
Use GET for AJAX Requests
Use GET for AJAX Requests
tag: server
The Yahoo! Mail team found that when using XMLHttpRequest, POST is implemented in the browsers as a two-step process: sending the headers first, then sending data. So it's best to use GET, which only takes one TCP packet to send (unless you have a lot of cookies). The maximum URL length in IE is 2K, so if you send more than 2K data you might not be able to use GET.
An interesting side affect is that POST without actually posting any data behaves like GET. Based on the HTTP specs, GET is meant for retrieving information, so it makes sense (semantically) to use GET when you're only requesting data, as opposed to sending data to be stored server-side.
@binnng
binnng / gist:8053128
Created December 20, 2013 10:42
-webkit-overflow-scrolling: touch 在 iOS7 中得一个BUG
/**
* iOS7 BUG
* 元素A覆盖在元素B上
* 元素B定义 -webkit-overflow-scrolling: touch 样式
* 滑动元素A会穿透A而滑动到B
* 外部表现:滑动A页面无响应
*/
/*-webkit-overflow-scrolling: touch;*/
overflow: scroll;
@binnng
binnng / gist:7908132
Created December 11, 2013 10:24
No way to input text on popups form with Android 2.3.7
https://github.com/jquery/jquery-mobile/issues/6116
@binnng
binnng / gist:7886442
Created December 10, 2013 06:16
通过设置响应头解决跨域问题
Access-Control-Allow-Origin: http://foo.example
允许跨域的域
Access-Control-Allow-Methods: POST, GET, OPTIONS
允许跨域执行的方法
Access-Control-Allow-Headers: X-PINGOTHER
允许跨域设置的头信息
Access-Control-Max-Age: 1728000
@binnng
binnng / gist:6881326
Last active December 24, 2015 23:38
随机打乱数组
var arr = [1, 2, 3, 4, 5];
arr.sort(function (a, b) {
return Math.random()>.5 ? -1 : 1;//用Math.random()函数生成0~1之间的随机数与0.5比较,返回-1或1
});
@binnng
binnng / gist:6102897
Last active December 20, 2015 08:49
CSS transition 渐变显示元素
/*
*元素渐变显示
*/
.banner_item{
display: inline-block;
background-size: 100%;
width: 814px;
height: 316px;
overflow: hidden;
background-repeat: no-repeat;
@binnng
binnng / gist:6098268
Created July 28, 2013 11:29
正则的贪婪模式
//开启贪婪模式
/a(.*)z/.exec('aszdfffz');
//禁止贪婪模式
a(.*?)z/.exec('aszdfffz');
@binnng
binnng / gist:6077636
Created July 25, 2013 07:47
在三星大部分手机上,如果想让子元素skew,必须要设置父元素skew(0deg)才行。
<p class="title">
<b></b>
<span>科鲁兹人气榜</span>
</p>
@binnng
binnng / gist:6069033
Created July 24, 2013 09:00
JS判断移动端访问设备并解析对应CSS
// 判断是否为移动端运行环境
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") < 0) {
try {
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {