js实现图片延迟加载原理
<img src="data:image/1188695.png" alt="taobao" trueImg="image/1.jpg" id="img"/>
js
var img=document.querySelector("#img");
window.setTimeout(function (){
var oImg=document.createElement('img');
oImg.src=img.getAttribute('trueImg');
oImg.onload=function(){
img.src=this.src;
oImg=null;
}
},500);
所有的事件绑定都是异步编程
js盒子模型:
clientHeight=内容的高度+上下填充;
offsetHeight=clientHeight+上下边框;
clientTop=borderTop;
offsetTop:父级定位元素的上偏移量->margin(自己最外边到border)
scrollHeight:一般都是约数,在不同的浏览器中获取到的结果是不同的
scrollTop:滚动条减去的宽度或者高度
document.documentElement.scrollTop=0;
document.body.scrollTop=0;
<a href="javascript:void 0;">跳转页面</a>
取消a标签默认行为
<a href="#">跳转页面</a>
刷新当前页面
var timer1=setTimeout(function(){
console.log(11);
},1000);
console.log(timer1);
window.clearTimeout(1);
最新文章
- IIS Connection Timeout vs httpRuntime executionTimeout
- ubuntu 服务管理
- 静默安装oracle11G
- 【转】fread函数和fwrite函数
- C/C++堆栈指引(转)
- MySQL在大数据Limit使用
- 详解常用的gulp命令
- tty各种设备的情况
- EDB日志配置-慢sql记录分析
- mysql登录1045错误时 修改登录密码
- 做接口自动化时候,一些登录头信息可以通过aop的方式进行增强
- ps -ef | grep Linux进程查看命令
- LabVIEW--为控件添加说明信息
- Oracle11g 体系结构
- CSS属性大全
- Vuejs选项卡案例
- tile38 复制配置
- AMD 与CMD
- 基于express+mongodb+pug的博客系统——后台篇
- 浅谈iOS内存管理机制