tips
window.location.protocol+"//"+window.location.host; 获取当前连接host
err http://10.0.20.23/wechat/js_sdk/ajaxWx?jsonpcallback=1&callback=jQuery331012469225729991806_1586917741798&url=http%253A%252F%252F10.0.20.23%252Fminvite%252F&_=1586917741799 获取了本地host 接口错误
err Uncaught SyntaxError: Unexpected token '<' 请求接口 datatype :1-jsonp导致 2-“eval”函数是出错
tips
parseInt()和parseFloat()两个转换函数 只有对String类型调用这些方法,这两个函数才能正确运行;对其他类型返回的都是NaN(Not a Number)。
tips
document.body--窗口文档body document.documentElement 窗口文档html .scrollTop默认产生滚动条给到html||body,当子元素产生滚动条后 赋予子元素 window.pageYOffset
.offset().top 相对于文档 document.getElementsByClassName("b")[0].offsetTop相对于父元素第一个position不为static元素
document.documentElement.scrollHeight 计算元素 高度+滚动条高度body 100% body>div设置overflow-x=hidden document.documentElement.scrollHeight为浏览器高度,div下子元素设置overflow-x=hidden; 则div内的子元素高度不计算在内
err Disable Unnecessary escape character: \/ no-useless-escape 1:禁用不必要的转义符:\ / no-useless-escape 可能 正则表达式未取到 验证对象导致的
err fatal: refusing to merge unrelated histories 合并提交 版本错位 可加参数 --allow-unrelated-histories 尝试
tips
在IE6中有另一个隐含的属性叫做hasLayout,该属性的作用和BFC类似,所以IE6浏览器可以通过开hasLayout来解决问题。开启方式有很多,但是副作用最小的方式是: 直接将元素的zoom设置为1即可
tips
clipbord 复制部分失败 尝试在复制按钮处添加 cursor:pointer; 无效可尝试添加点击事件
$(".copywx").click(function () {alert("已复制微信,马上去添加好友");});
禁止触摸点击 touch-action: none;
#去除ifram的滚动条;
.inner-container {
position: absolute; left: 0;
overflow-x: hidden;
overflow-y: scroll;
}
/* for Chrome 只针对谷歌浏览器*/
.inner-container::-webkit-scrollbar {
display: none;
}
<body class="inner-container">
.outer-container {
position: relative;
overflow: hidden;
}
<body >
<div class="outer-container">
<iframe marginWidth=0 marginHeight=0 src="demo1.html" scrolling="auto" frameBorder=0 width="100%"></iframe>
</div>
</body>
$(document).click() 在iphone上不触发事件解决办法
<div class="name">点我</div>
(document).on(“click touchstart”, “.name”, function() {
alert(“name”);
});
复制/赋值时input弹出键盘 input.setAttribute('readonly', 'readonly');
const btn = document.querySelector('#btn');
btn.addEventListener('click',() => {
var input = document.createElement('input');
input.setAttribute('readonly', 'readonly');
input.setAttribute('value', 'hello world');
document.body.appendChild(input);
input.setSelectionRange(0, 9999);
if (document.execCommand('copy')) {
document.execCommand('copy');
console.log('复制成功');
}
document.body.removeChild(input);
})
2018/1/19添加
这个现在微信打开,安卓事件也是没有触发,上面2种方法依然适用,但是touchstart个人觉得滑动页面的时候会误触,还是喜欢用click + cursor
ios input button背景色不起作用的
input[type=button], input[type=submit], input[type=file], button { cursor: pointer; -webkit-appearance: none; }
background改成background-color
网友评论