non ho ancora provato il tuo codice perchè ero alle prese con autoesperimenti
Un modo che ho provato è questo.
Metto un segnaposto alla fine della pagina e ne ricavo la posizione y. L'aumento di 18 px per tenere conto del salto riga e ridimensiono la finestra.
Allora, con IE6 e Firefox ottengo buoni risultati, sia con poche righe di tabella, sia con molte righe, perchè i browser si dimensionano alla max altezza visibile.
CON OPERA 9 NON FUNZIONA
il popup è aperto con la solita:
window.open("a.asp", "popup","top=0px,left=0px,width=500px,height=500px ,resizable=yes,scrollbars=yes");
la pagina asp (se non si usa asp, basta mettere una tabella con x righe) è:
le altre funzioni di libreria sonocodice:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Pagina senza titolo</title> <script type="text/javascript" src="../js/libreria.js"></script> <script language="javascript" type="text/javascript"> // <!CDATA[ function window_onload() { var y = getRealTop($("br1")); ridimensiona(y); } function ridimensiona(y) { window.setTimeout(function() {onsetTimeoutRidimensiona(y);}, 300);}; function onsetTimeoutRidimensiona(y) { var wh = ClientSize(); var w = wh.width; var h = wh.height; window.resizeBy(0, y - h + 18); } // ]]> </script> </head> <body onload="return window_onload()"> <table border="1"> <%for i=1 to 15 %> <tr><td><%=i %></td></tr> <%next %> </table> <br id="br1" style="font-size:0pt;" /> </body> </html>
codice:/*---------------------------------------------------------------------------------------- //restituisce in un oggetto {width:myWidth, height:myHeight } //lo spazio utile interno del browser //esempio: function window_onresize() { var wh = ClientSize(); var w = wh.width; var h = wh.height; } -----------------------------------------------------------------------------------------*/ function ClientSize() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } return {width:myWidth, height:myHeight }; } //al posto di mettere document.getElementById("div1"), mettere $("div1") //da prototype.js function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } //----------------------------------------------------------------------- //restituisce la coordinata y di un elemento rispetto alla pagina //----------------------------------------------------------------------- function getRealTop(el) { if (arguments.length==0) el = this; if(el == undefined) return 0; yPos = el.offsetTop; tempEl = el.offsetParent; while (tempEl != null) { yPos += tempEl.offsetTop; tempEl = tempEl.offsetParent; } return yPos; }![]()

Rispondi quotando