Internet Explorer 中的 Window.screen 和多个监视器
Window.screen in Internet Explorer and more than one monitor
我有一个具有不同屏幕分辨率的双显示器设置,当我在Chrome中访问此页面时,它显示了两个屏幕的正确分辨率。但是IE只显示我的主屏幕的分辨率。它比在IE window.screen.availWidth
中出现,window.screen.availHeight
只返回主屏幕的值。我可以获取运行 Internet Explorer 的第二个屏幕的屏幕分辨率吗?
使用在 http://archive.cpradio.org/code/javascript/dual-monitors-and-windowopen/找到的古代代码
function FindLeftWindowBoundry()
{
// In Internet Explorer window.screenLeft is the window's left boundry
if (window.screenLeft)
{
return window.screenLeft;
}
// In Firefox window.screenX is the window's left boundry
if (window.screenX)
return window.screenX;
return 0;
}
window.leftWindowBoundry = FindLeftWindowBoundry;
// Find Left Boundry of the Screen/Monitor
function FindLeftScreenBoundry()
{
// Check if the window is off the primary monitor in a positive axis
// X,Y X,Y S = Screen, W = Window
// 0,0 ---------- 1280,0 ----------
// | | | --- |
// | | | | W | |
// | S | | --- S |
// ---------- ----------
if (window.leftWindowBoundry() > window.screen.width)
{
return window.leftWindowBoundry() - (window.leftWindowBoundry() - window.screen.width);
}
// Check if the window is off the primary monitor in a negative axis
// X,Y X,Y S = Screen, W = Window
// 0,0 ---------- -1280,0 ----------
// | | | --- |
// | | | | W | |
// | S | | --- S |
// ---------- ----------
// This only works in Firefox at the moment due to a bug in Internet Explorer opening new windows into a negative axis
// However, you can move opened windows into a negative axis as a workaround
if (window.leftWindowBoundry() < 0 && window.leftWindowBoundry() > (window.screen.width * -1))
{
return (window.screen.width * -1);
}
// If neither of the above, the monitor is on the primary monitor whose's screen X should be 0
return 0;
}
window.leftScreenBoundry = FindLeftScreenBoundry;
console.log(window.screen.width);
console.log(window.leftScreenBoundry());
console.log(window.screen.height);
我知道这并不多,但它至少可以让您评估客户端是否在双显示器集上以及该集有多宽。
IE唯一需要做的事情就是在所有蒙特人之间均匀地分配分辨率。
因此,它取总宽度并将其除以显示器数量。
我有 3 台显示器,2 台为 1920 x 1080,一台为 1600 x 900 用于我的测试,IE 给出的左侧位置为 1745 0 -1745,所以是的......IE总体上有些问题,但希望这个小片段对您有所帮助,或者其他人正在为IE制作半兼容代码。
相关文章:
- Windows 8高速监视器iframe导航
- 如何在PhantomJS中更改window.screen尺寸
- 通过web应用程序获取客户端监视器的分辨率
- 检测监视器的物理尺寸
- 如果screen.height低于460px,请删除一个类
- 如何将 screen.width 值替换为我自己定义的值
- 如果screen.width<=480,只有一次;第一次通过移动设备见面
- window.screen.width和window.screen.height在iPad3上不起作用
- 如何创建覆盖整个监视器的全屏库
- jquery Animate Number reanimate on screen enter
- window.screen in FireFox
- Alart or modal screen javascript
- 当屏幕 CSS 像素比大于 1 时,在不同的浏览器上获取相同的 window.screen.height 和 windo
- Android浏览器的screen.width,screen.height和window.innerWidth和wind
- 如何滚动以在屏幕底部设置 DIV 的底部(监视器)
- 将元素的宽度设置为等于监视器大小,而不会在缩放时发生变化
- Internet Explorer 中的 Window.screen 和多个监视器
- 在辅助监视器上使用 java 脚本全屏打开 IE 时出现问题
- jQuery In Custom Login Screen xhtml
- 监视器shell脚本's日志文件