随笔分类 - js
js相关
摘要://小程序跳转小程序 wx.navigateToMiniProgram({ appId: '目标小程序appid', path: '目标小程序页面路径', //develop开发版;trial体验版;release正式版 envVersion: 'release', success(res) { /
阅读全文
摘要:<meta name="viewport" content="width=device-width,initial-scale=0.3,maximum-scale=1,user-scalable=0"> //兼容ios document.addEventListener('gesturestart'
阅读全文
摘要:document.addEventListener('click', (e) => { let screenDoc = document.querySelector('.screen-box'); if (screenDoc && !screenDoc.contains(e.target)) { /
阅读全文
摘要://上传头像到服务器 function uploadFile() { console.log(344) var pic = $('#upload')[0].files[0]; var file = new FormData(); file.append('image', pic); $.ajax({
阅读全文
摘要:窗口可视区域宽度: document.documentElement.clientWidth || document.body.clientWidth; 窗口可视区域高度: document.documentElement.clientHeight || document.body.clientHe
阅读全文
摘要:function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (
阅读全文
摘要://判断手机设备 var u = navigator.userAgent; if(u.match(/iPhone/i) || u.match(/Android/i) || u.match(/iPod/i)){ console.log('手持设备') } //判断IPad设备 if(navigator
阅读全文
摘要:function getCookie(name){ var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)){ return unescape(arr[2]); }else{ re
阅读全文
摘要:js方法: parent.document; jquery方法: $('#test',parent.document); //此处的选择器为父页面的选择器
阅读全文
摘要:1、冒泡排序 var str = [12,55,33,66]; str.sort(_sort) function _sort(a,b){ if(a < b){ return -1; }else if(a > b){ return 1; }else{ return 0; } } 2、数组去重es6 v
阅读全文
摘要:参数 options 类型:Object 可选。AJAX 请求设置。所有选项都是可选的。 async 类型:Boolean 默认值: true。默认设置下,所有请求均为异步请求。如果需要发送同步请求,请将此选项设置为 false。 注意,同步请求将锁住浏览器,用户其它操作必须等待请求完成才可以执行。
阅读全文