This file contains hidden or 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
| function f(n) { | |
| return n < 10 ? '0' + n : n; | |
| } | |
| Date.prototype.toJSON = function () { | |
| return isFinite(this.valueOf()) | |
| ? this.getUTCFullYear() + '-' + | |
| f(this.getUTCMonth() + 1) + '-' + | |
| f(this.getUTCDate()) + 'T' + | |
| f(this.getUTCHours()) + ':' + |
This file contains hidden or 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
| function getElementLeft(elem) { | |
| var left = elem.offsetLeft, | |
| current = elem.offsetParent; | |
| while (current) { | |
| left += current.offsetLeft; | |
| current = current.offsetParent; | |
| } | |
| return left; |
This file contains hidden or 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 ruleRegex = /^(.+?)\[(.+)\]$/, | |
| numericRegex = /^[0-9]+$/, | |
| integerRegex = /^\-?[0-9]+$/, | |
| decimalRegex = /^\-?[0-9]*\.?[0-9]+$/, | |
| emailRegex = /^[a-zA-Z0-9.!#$%&'*+\-\/=?\^_`{|}~\-]+@[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*$/, | |
| alphaRegex = /^[a-z]+$/i, | |
| alphaNumericRegex = /^[a-z0-9]+$/i, | |
| alphaDashRegex = /^[a-z0-9_\-]+$/i, | |
| naturalRegex = /^[0-9]+$/i, | |
| naturalNoZeroRegex = /^[1-9][0-9]*$/i, |
This file contains hidden or 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
| JSON.parse(JSON.stringify(obj)); |
This file contains hidden or 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
| function contains(parentNode, childNode) { | |
| if (parentNode.contains) { | |
| return parentNode != childNode && parentNode.contains(childNode); | |
| } else { | |
| return !!(parentNode.compareDocumentPosition(childNode) & 16); | |
| } | |
| } | |
| /* |
This file contains hidden or 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
| webkitProperty | |
| MozProperty | |
| msProperty | |
| OProperty | |
| property | |
| myself.style.webkitTransform = ""; | |
| myself.style.MozTransform = ""; | |
| myself.style.msTransform = ""; | |
| myself.style.OTransform = ""; |
This file contains hidden or 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 jsonStr = '{"name": "w3help", "url": "www.w3help.org", "tech": ["js", "HTML", "CSS", 5, 4.01, 2.1],' | |
| + '"online": true, "category": {"RCA": "Root Cause Artical", "KB":"Knowledge Base"},' | |
| + '"version": 1}'; | |
| json2 = (new Function("return " + jsonStr))(); | |
| for(p in json2) { | |
| alert(json2[p]); | |
| } |
This file contains hidden or 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
| webkit: | |
| 主要有下面7个属性 | |
| ::-webkit-scrollbar 滚动条整体部分,可以设置宽度 | |
| ::-webkit-scrollbar-button 滚动条两端的按钮 | |
| ::-webkit-scrollbar-track 外层轨道 | |
| ::-webkit-scrollbar-track-piece 内层滚动槽 |
This file contains hidden or 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 (!String.prototype.trim) { | |
| String.prototype.trim = function() { | |
| return this.replace(/^\s+/, "").replace(/\s+$/, ""); | |
| }; | |
| } |
This file contains hidden or 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 script = document.createElement("script"); | |
| if (script.readyState) { | |
| script.onreadystatechange = function() { | |
| if (script.readyState == "loaded" || script.readyState == "complete") { | |
| script.onreadystatechange = null; | |
| alert("ie"); | |
| } | |
| } | |
| } else { |
OlderNewer