Hi, all, My use the prototype from http://www.prototypejs.org/assets/2008/9/29/prototype-1.6.0.3.js . I use the getDimensions function to get the size of the windows like this
<head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Get The Width And Height Of The Browser</title> </head> <script src="prototype-1.6.0.3.js"></script> <!-- <script src="prototype-1.6.0.3.alin.js"></script> --> <script type="text/javascript"> function on_window_resize() { var size = document.viewport.getDimensions(); $("height").value = size.height; $("width").value = size.width; } </script> <body onresize="on_window_resize()" onload="on_window_resize()"> Width:<input type="text" id="width" /><br /> Height:<input type="text" id="height" /><br /> </body> but the result is wrong except IE. I try it in the Firefox, Opera and ... the browser, the result is wrong. I modify the getDimensions, and it can works in Firefox , safari and Opera now. But I don't know whether is a bug ? This is my "patch ??" a...@alin-laptop:~/Documents$ cat /home/alin/Desktop/getDimensions/ getDimensions.patch 2694,2700c2694,2697 < if (B.WebKit && !document.evaluate) { < // Safari <3.0 needs self.innerWidth/Height < dimensions[d] = self['inner' + D]; < } else if (B.Opera && parseFloat(window.opera.version()) < 9.5) { < // Opera <9.5 needs document.body.clientWidth/Height < dimensions[d] = document.body['client' + D] < } else { --- > /* Modify by Fang Yunlin, mail: cst05...@gmail.com, MSN: > cst05...@hotmail.com */ > /*=======Begin========*/ > if (B.IE) { > //IE 7.0(Windows) 2701a2699,2701 > } else { > //Firefox 3.0.7(Windows), Firefox 3.0.7(Linux), Opera 9.64(Windows), > Opera 9.64(Linux), Safari 3.2.2(Windows), Chrome 2.0.166.1(Windows), > Konqueror 4.2.00(Linux), Epiphany 2.24.1(Linux) > dimensions[d] = self['inner' + D]; 2703c2703,2704 < }); --- > /*=======End=========*/ > }); 4320c4321 < Element.addMethods(); \ No newline at end of file --- > Element.addMethods(); This is the function after I modify: document.viewport = { getDimensions: function() { var dimensions = { }, B = Prototype.Browser; $w('width height').each(function(d) { var D = d.capitalize(); /* Modify by Fang Yunlin, mail: cst05...@gmail.com, MSN: cst05...@hotmail.com */ /*=======Begin========*/ if (B.IE) { //IE 7.0(Windows) dimensions[d] = document.documentElement['client' + D]; } else { //Firefox 3.0.7(Windows), Firefox 3.0.7(Linux), Opera 9.64 (Windows), Opera 9.64(Linux), Safari 3.2.2(Windows), Chrome 2.0.166.1 (Windows), Konqueror 4.2.00(Linux), Epiphany 2.24.1(Linux) dimensions[d] = self['inner' + D]; } /*=======End=========*/ }); return dimensions; }, 2685,20 62% Thank You ! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---