Javascript 如何在IE11中使用window.screenLeft,以及子帧和缩放
Javascript 如何在IE11中使用window.screenLeft,以及子帧和缩放,javascript,html,internet-explorer,internet-explorer-11,Javascript,Html,Internet Explorer,Internet Explorer 11,window.screenLeft返回正确的值,无论您在“主框架”中使用何种缩放 通过正确的值,我的意思是将它们乘以window.devicePixelRatio,就可以成功地获得呈现文档的视图相对于设备屏幕的X偏移量(以屏幕像素为单位) 当您在子帧中时(使用标记),缩放为100%时一切正常 但是,当您在子帧中,缩放不为100%时,返回的值没有意义,afaict 示例,确定(子帧,缩放100%) 示例,KO(子帧,缩放150%) 资料来源1:主框架: <html> <
window.screenLeft
返回正确的值,无论您在“主框架”中使用何种缩放
通过正确的值,我的意思是将它们乘以window.devicePixelRatio
,就可以成功地获得呈现文档的视图相对于设备屏幕的X偏移量(以屏幕像素为单位)
当您在子帧中时(使用
标记),缩放为100%时一切正常
但是,当您在子帧中,缩放不为100%时,返回的值没有意义,afaict
示例,确定(子帧,缩放100%)
示例,KO(子帧,缩放150%)
资料来源1:主框架:
<html>
<head>
<title>SO</title>
</head>
<table>
<tr>
<td>
Text in the Main Frame
</td>
<td>
<iframe width=600 height=450 name="SomeFrame" src="src2.html"></iframe>
</td>
</tr>
</table>
</html>
所以
主框架中的文本
来源2:子帧
<html>
<head>
<title>SO (frame)</title>
<script>
function DoTheCalc() {
document.getElementById( "W_L" ).value = window.screenLeft;
document.getElementById( "W_T" ).value = window.screenTop;
document.getElementById( "P_R" ).value = window.devicePixelRatio;
document.getElementById( "W_X" ).value = window.screenLeft * window.devicePixelRatio;
document.getElementById( "W_Y" ).value = window.screenTop * window.devicePixelRatio;
return;
}
</script>
</head>
<body bgcolor='green'>
<input type="button" id="CALC_BUT" value="Compute" onclick="DoTheCalc();"/>
<br/>
<label>
screenLeft
<input id="W_L"/>
</label><br/>
<label>
screenTop
<input id="W_T"/>
</label>
<br/>
<label>
Pixel Ratio
<input id="P_R"/>
</label><br/>
<label>
Left, Zoom adjusted
<input id="W_X"/>
</label><br/>
<label>
Top, Zoom adjusted
<input id="W_Y"/>
</label>
<body>
</html>
SO(框架)
函数DoTheCalc(){
document.getElementById(“W_L”).value=window.screenLeft;
document.getElementById(“W_T”).value=window.screenTop;
document.getElementById(“P_R”).value=window.devicePixelRatio;
document.getElementById(“W_X”).value=window.screenLeft*window.devicePixelRatio;
document.getElementById(“W_Y”).value=window.screenTop*window.devicePixelRatio;
返回;
}
屏幕左
屏幕
像素比
左,缩放调整
顶部,缩放调整
MSIE浏览器默认在顶部窗口的中心向下缩放变换原点。。。其他浏览器从左上角变换。在顶部窗口中居中放置表格(使用css,而不是“降价对齐”属性)。要测试并降低缩放级别。。。MSIE浏览器将沿中心线向下转换。。。。其他浏览器将从左上角转换。@Robbarsons好的,但是我的问题呢?缩放子帧的window.screenLeft
代表什么?