window.onresize = function () { var ua = navigator.userAgent; var isAndroid = /android/i.test(ua); //android终端 if(isAndroid) { if (document.activeElement.tagName == "INPUT" || document.activeElement.tagName == "TEXTAREA") { window.setTimeout(function() { document.act...
<input id="txt" type="text">//字符串截取function getByteVal(val, max) { var returnValue = ''; var byteValLen = 0; for (var i = 0; i < val.length; i++) { if (val[i].match(/[^\x00-\xff]/ig) != null) byteValLen += 2; else byteValLen += 1; if (byteValLen >...
$('#content').on("mousewheel DOMMouseScroll", function (event) { // chrome & ie || // firefox var delta = (event.originalEvent.wheelDelta && (event.originalEvent.wheelDelta > 0 ? 1 : -1)) || (event.originalEvent.detail && (event.originalEvent.detail > 0 ...
function parseUA() { var u = navigator.userAgent; var u2 = navigator.userAgent.toLowerCase(); return { //移动终端浏览器版本信息 trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKit: u.indexOf('AppleWebKit') > -1, ...
1.正方形
square {width: 100px; height: 100px; background: red;}
2.长方形
rectangle { width: 200px; height: 100px; background: red;}3.左上三角
triangle-topleft { width: 0; height: 0; border-top: 100px solid red; border-right: 100px solid transparent; }4.右上三角
triangle-topright { width...
function formatDate(now) { var y = now.getFullYear(); var m = now.getMonth() + 1; // 注意js里的月要加1 var d = now.getDate(); var h = now.getHours(); var m = now.getMinutes(); var s = now.getSeconds(); return y + "-" + m + "-" + d + " " + h + ":" + m + ":" + s; ...
function getRandomColor () { const rgb = [] for (let i = 0 ; i < 3; ++i){ let color = Math.floor(Math.random() * 256).toString(16) color = color.length == 1 ? '0' + color : color rgb.push(color) } return '#' + rgb.join('')}
文章转载于:https://www.jianshu.com/p/29b7eacfa...
/** * 自定义封装jsonp方法 * @param options */jsonp = function(options) { options = options || {}; if (!options.url || !options.callback) { throw new Error("参数不合法"); } //创建 script 标签并加入到页面中 var callbackName = ('jsonp_' + Math.random()).replace(".", ""); var oHead...
//写cookiessetCookie = function(name, value, time) { var strsec = getsec(time); var exp = new Date(); exp.setTime(exp.getTime() + strsec * 1); document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();}//cookie操作辅助函数getsec = function(str) { var str1 = str...
/** * 生成随机字符串(可指定长度) * @param len * @returns {string} */randomString = function(len) { len = len || 8; var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ var maxPos = $chars.length; var pwd = ''; for (va...