...il fatto è che io ho fatto una ricerca su internet e mi era sembrato di carpire questo...forse hai ragione tu, occorre prima provare, solo una cosa, come posso fare ad integrare le due funzioni, cioè quella che mi hai scritto tu + l'esempio che mi hai indicato? Basta semplicemente unirle all'interno di una pagina htm, in questo modo?
codice:onload = function(){ var div = simplePopUnder( "Hello World", {width: 200, heigth: 60}, {text: "#FFF", background: "#444"}, {style: "solid", color: "#000", size:2}, 4 ); }; function simplePopUnder(// (C) Andrea Giammarchi content, // Element (to append) or String (to write with innerHTML) sizeo, // Object, optional - {width:Number, height:Number} colorso, // Object, optional - {text:String, background:String} bordero, // Object, optional - {style:String, color:String, size:Number} paddingn // Number, optional ){ function c(v, pre){return (pre || "").concat(parseInt(v), "px")}; var div = document.createElement("div"), all = document.getElementsByTagName("*"), i = 0, zIndexn = 1234567; for(; i < all.length; i++) zIndexn = Math.max(zIndexn, all[i].style.zIndex || zIndexn); with(div.style) { position = "absolute"; zIndex = zIndexn; if(sizeo) { if(sizeo.width) { left = "50%"; width = c(sizeo.width); marginLeft = c(sizeo.width/2, "-"); } if(sizeo.heigth) { top = "50%"; heigth = c(sizeo.heigth); marginTop = c(sizeo.heigth/2, "-"); } }; if(colorso) { if(colorso.text) color = colorso.text; if(colorso.background) backgroundColor = colorso.background; }; if(bordero) { if(bordero.style) borderStyle = bordero.style; if(bordero.color) borderColor = bordero.color; if(bordero.size) borderWidth = c(bordero.size); }; if(paddingn) padding = c(paddingn); }; document.body.appendChild(div); if(content.constructor === String) div.innerHTML = content; else div.appendChild(content); return div; };

Rispondi quotando