This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* iOS7 BUG | |
* 元素A覆盖在元素B上 | |
* 元素B定义 -webkit-overflow-scrolling: touch 样式 | |
* 滑动元素A会穿透A而滑动到B | |
* 外部表现:滑动A页面无响应 | |
*/ | |
/*-webkit-overflow-scrolling: touch;*/ | |
overflow: scroll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/jquery/jquery-mobile/issues/6116 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*元素渐变显示 | |
*/ | |
.banner_item{ | |
display: inline-block; | |
background-size: 100%; | |
width: 814px; | |
height: 316px; | |
overflow: hidden; | |
background-repeat: no-repeat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//开启贪婪模式 | |
/a(.*)z/.exec('aszdfffz'); | |
//禁止贪婪模式 | |
a(.*?)z/.exec('aszdfffz'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p class="title"> | |
<b></b> | |
<span>科鲁兹人气榜</span> | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 判断是否为移动端运行环境 | |
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)) { |
NewerOlder