<a href="http://www.basecss.net/" rel="sidebar">收藏本站</a>
目前只有 FireFox 支持,新版 Opera 启用 Webkit 内核之后已经不再支持。
function deepClone(target) { | |
if(typeof target !== 'object') { | |
return target; | |
} | |
if(target.constructor === RegExp) { | |
return target; | |
} | |
var result = new target.constructor(); |
<style> | |
@media (min-device-width:600px) { | |
img[data-src-600px] { | |
content: attr(data-src-600px, url); | |
} | |
} | |
@media (min-device-width:800px) { | |
img[data-src-800px] { | |
content: attr(data-src-800px, url); |
function fetchJSON(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'json';
xhr.send();
xhr.onload = function() {
if(xhr.response) {
resolve(xhr.response);
/Apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "F:/xxx/xxx" <- code
ServerName myhost.example.com
ErrorLog "logs/myhost.example.comm-error.log"
CustomLog "logs/myhost.example.com-access.log" common
// Install n from npm
$ sudo npm install -g n
// Install different version for Node.js
$ sudo n 0.12.0
$ sudo n 0.10.36
// Quickly switch between the Node.js version with the command n
$ n
<input type="text" id="search" name="" autofocus> | |
<script type="text/javascript"> | |
(function(inputField){ | |
// typeof inputField.autofocus === 'boolean' | |
// or !inputField.autofocus | |
if(inputField.autofocus !== true){ | |
inputField.focus(); | |
} | |
})(document.getElementById('search')); |
(function(win, doc){ | |
var $ = function(selector) { | |
// 获取元素的方法映射 | |
var matches = { | |
'#': 'getElementById', | |
'.': 'getElementsByClassName', | |
'@': 'getElementsByName', | |
'*': 'getElementsByTagName', |
/* | |
* 浅复制,子类实例引用类型属性的修改会影响父类对应的属性 | |
*/ | |
function clone(parent, child) { | |
var i; | |
child = child || {}; | |
for(i in parent){ | |
if(parent.hasOwnProperty(i)){ |