多层iframe嵌套的时候,取最底层iframe页面鼠标点击的XY坐标,
IE下测试通过~
/** * 获取最底层iframe页面中鼠标点击的位置 */ function getPosition_Iframe(){ var parentWindow = window.parent; var tmpLocation = window.location; var target = null; var left=0; var top=0; while(parentWindow!=null && typeof(parentWindow)!='undefined' && tmpLocation!=parentWindow.location){ for(var x=0;x< parentWindow.frames.length;x++){ if(tmpLocation == parentWindow.frames[x].location){ target = parentWindow.frames[x].frameElement; break; } } do { left += target.offsetLeft - target.scrollLeft|| 0; top += target.offsetTop - target.scrollTop || 0; target = target.offsetParent; } while(target); tmpLocation=parentWindow.location; parentWindow = parentWindow.parent; } return {x:left+window.event.clientX,y:top+window.event.clientY}; }