2016-02-08 19 views
7

Ho una configurazione a doppio monitor con diverse risoluzioni dello schermo e quando visito lo this page in Chrome mostra la risoluzione corretta per entrambi gli schermi. Ma IE mostra solo la risoluzione del mio schermo principale. Appare rispetto a IE window.screen.availWidth e window.screen.availHeight restituisce solo i valori per la schermata principale. Posso ottenere la risoluzione dello schermo per il secondo schermo che esegue Internet Explorer?Window.screen in Internet Explorer e più di un monitor

+0

di quale versione stiamo parlando, versione minima supportata ecc. – Tschallacka

+0

IE8 (IE11 in modalità IE8) sarebbe ottimo, ma solo IE11 andrebbe bene. –

risposta

4

Utilizzando antico codice trovato su http://archive.cpradio.org/code/javascript/dual-monitors-and-windowopen/

function FindLeftWindowBoundry() 
 
{ 
 
\t // In Internet Explorer window.screenLeft is the window's left boundry 
 
\t if (window.screenLeft) 
 
\t { 
 
\t \t return window.screenLeft; 
 
\t } 
 
\t 
 
\t // In Firefox window.screenX is the window's left boundry 
 
\t if (window.screenX) 
 
\t \t return window.screenX; 
 
\t \t 
 
\t return 0; 
 
} 
 

 
window.leftWindowBoundry = FindLeftWindowBoundry; 
 

 
// Find Left Boundry of the Screen/Monitor 
 
function FindLeftScreenBoundry() 
 
{ 
 
\t // Check if the window is off the primary monitor in a positive axis 
 
\t // X,Y     X,Y     S = Screen, W = Window 
 
\t // 0,0 ---------- 1280,0 ---------- 
 
\t //  |   |   | ---  | 
 
\t //  |   |   | | W | | 
 
\t //  |  S |   | --- S | 
 
\t //  ----------   ---------- 
 
\t if (window.leftWindowBoundry() > window.screen.width) 
 
\t { 
 
\t \t return window.leftWindowBoundry() - (window.leftWindowBoundry() - window.screen.width); 
 
\t } 
 
\t 
 
\t // Check if the window is off the primary monitor in a negative axis 
 
\t // X,Y     X,Y     S = Screen, W = Window 
 
\t // 0,0 ---------- -1280,0 ---------- 
 
\t //  |   |   | ---  | 
 
\t //  |   |   | | W | | 
 
\t //  |  S |   | --- S | 
 
\t //  ----------   ---------- 
 
\t // This only works in Firefox at the moment due to a bug in Internet Explorer opening new windows into a negative axis 
 
\t // However, you can move opened windows into a negative axis as a workaround 
 
\t if (window.leftWindowBoundry() < 0 && window.leftWindowBoundry() > (window.screen.width * -1)) 
 
\t { 
 
\t \t return (window.screen.width * -1); 
 
\t } 
 
\t 
 
\t // If neither of the above, the monitor is on the primary monitor whose's screen X should be 0 
 
\t return 0; 
 
} 
 

 
window.leftScreenBoundry = FindLeftScreenBoundry; 
 

 
console.log(window.screen.width); 
 
console.log(window.leftScreenBoundry()); 
 

 
console.log(window.screen.height);

io so che non è molto, ma sarà almeno permetterà di valutare se il client è su un doppio monitor impostato e la larghezza il set è.

L'unica cosa importata da IE è distribuire la risoluzione in modo uniforme tra tutti i montatori.

Quindi occupa una larghezza totale e lo divide per numero di monitor.

Ho 3 monitor, 2 a 1920 x 1080 e uno a 1600 x 900 per il mio test e IE ha dato la posizione a sinistra come 1745 0 -1745 quindi sì ... qualcosa è spento con IE in tutto, ma hopefull questo un piccolo frammento ti aiuterà, o qualcun altro un po 'più lontano sta facendo un codice semi-compatibile per IE.

+0

Ho già trovato quel codice e non posso usarlo. Il mio schermo sinistro è 1600x900 e il mio schermo destro 1920x1080. Lo schermo di destra è il mio schermo principale. 'window.leftScreenBoundry()' restituisce -1920 e questo è fuori dai limiti del mio desktop. –

+0

stesso qui. ha a che fare con l'ordinamento dei monitor e così via. non c'è molto che tu possa fare al riguardo. Che cosa stai cercando di ottenere? – Tschallacka

+0

ridimensionamento della finestra. Ho alcuni elementi dinamici, che mi impediscono di consentire a IE di gestire le dimensioni della finestra. –