常见的js兼容性问题

常见的 js 兼容性问题有哪些

    1. 弹框显示时,禁止背景滚动、并且记录滚动距离
1
2
3
4
5
6
7
8
9
10
11
// ****showDialog时****
// 1.设置body的position: fixed;
// 2. 记录滚动的距离 window.scrollY
Q.$("body").css("top", -window.scrollY + "px");
Q.$("body").css("position", "fixed");

// ***hideDialog时****
// 恢复body的默认属性
Q.$("body").css("position", "");
window.scrollTo(0, -parseInt(Q.$("body").css("top")));
Q.$("body").css("top", "");
    1. 获取事件
1
2
3
function (evt) {
var e = evt || window.event
}
    1. 事件 event 的属性,获取坐标,IE 下是,event.x/event.y,其他浏览器是 event.pageX/event.pageY
    1. 阻止超链接的默认行为
1
2
// IE是 event.returnValue= false
// 其他浏览器是 event.preventDefault()

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2024 HL's Blog All Rights Reserved.

UV : | PV :