GETBOUNDINGCLIENTRECT CAUSES 'UNSPECIFIED ERROR' IN IE7 AFTER AJAX in Jquery 1.4.2

来源:互联网 发布:cad for mac打不开 编辑:程序博客网 时间:2024/04/30 20:14

/*By Jiangong SUN*/


This problem occurs when we calculate the offset for hidden div in ajax in our project. It's produced in IE 7.


Here is the solution : 


In jquery.1.4.2.js,

replace :


var box = elem.getBoundingClientRect(),

with :

var box = null;try {    box = elem.getBoundingClientRect();} catch(e) {   box = { top : elem.offsetTop, left : elem.offsetLeft }};


In jquery.1.4.2.min.js,
replace :

var d=b.getBoundingClientRect(),

with :

try{var d=b.getBoundingClientRect();}catch(ex){var d={top:0,left:0,right:0,bottom:0};}

Enjoy coding !



原创粉丝点击