Marcel B February 2016

Window.screen in Internet Explorer and more than one monitor

I have a dual monitor setup with different screen resolutions and when I visit this page in Chrome it shows the right resoltion for both screens. But IE only shows the resolution of my primary screen. It appears than in IE window.screen.availWidth and window.screen.availHeight only returns the values for the primary screen. Can I get the screen resolution for the second screen running Internet Explorer?

Answers


Michael Dibbets February 2016

Using ancient code found at 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 (wi 

Post Status

Asked in February 2016
Viewed 1,481 times
Voted 8
Answered 1 times

Search




Leave an answer