Prendendo spunto da quanto postato sopra ho provato a realizzare una piccola demo che onload in base al size della finestra dovrebbe (ma non funzica) cambiare il colore dello sfondo al body.
Posto il codice.....
WINDOW.SIZE.JS
Codice PHP:
window.size = function() { var w = 0; var h = 0; //IE if(!window.innerWidth) { //strict mode if(!(document.documentElement.clientWidth == 0)) { w = document.documentElement.clientWidth; h = document.documentElement.clientHeight; } //quirks mode else { w = document.body.clientWidth; h = document.body.clientHeight; } } //w3c else { w = window.innerWidth; h = window.innerHeight; } return {width:w,height:h}; } window.center = function(){ if (this.window.size.width>(200)) document.getElementById("prova").setAttribute('background','red'); }
PAGE_HTML
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title></title> <script type="text/javascript" src="Window.Size.js"></script> <style> #provetta{ background:#ffffff;} </style> </head> <body id="prova" onload="window.center()"> blaaaaa </body> </html>
Help Meeee ..... dove sbaglio?
Grazie in anticipo
Denis