finestre & JavaScript |
|
aprire e chiudere finestre |
link per aprire una finestra: <a href="#" onclick='window.open("default.htm");> <a href="javascript:void('');" onclick='window.open("default.htm");> <a href="javascript:window.open('default.htm');">
link per chiudere una finestra: <a href="javascript:void('');" style="text-decoration:none" onClick='self.close()'> <a href="/" style="text-decoration:none" onClick='self.close()'> si puņ usare anche window.close(); per evitare l'alert di IE, si può mettere: <a href="/" style="text-decoration:none" onClick='window.open('', '_self', '');'>
anche le immagini possono esssere sensibili
solo IE consente di chiudere il browser
function Fine() {
Brow = navigator.appName;
if (navigator.appName == 'Microsoft Internet Explorer')
{ window.open('', '_self', ''); window.close(); }
else
{ alert('Your browser does not allow to close this window. Please close the browser to finish.'); }
}
|
nelle finestre create |
mettere: <meta name="ROBOTS" contents="NOINDEX, NOFOLLOW"> <body onload="top.window.focus()"> |
finestra a tutto schermo |
per chiudere la finestra, Alt-F4
<input type="button" onClick='window.open("form/default.htm",
"","fullscreen,scrollbars");' value="form & JavaScript">
|
una finestra su misura |
si adatta alla dimensione dell'immagine ed è pronta per chiudersi: provala.
<a href="#" onClick="finestra('etna.jpg');" title="cover"
style="font-size: 16px; font-weight: bold;">grande</a>
ecco il codice
<script type="text/javascript" language="Javascript">
function finestra(url){
if(typeof(url)!="object"){
window._w = window.open("","","width=30,height=30,scrollbars=no,resizable=yes");
window._w.document.open();
window._w.document.write('<html>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<center><table height="100%"><tr><td align="center" valign="middle">
<a href="javascript:window.close();">
<img alt="Click here to close" border="0" src="'+url+'" onLoad="opener.finestra(this);"></a>
<br><a href="javascript:window.close();"><font face="Verdana" size="2"><b>
Click here to close</font></b></a></td></tr></table></center></body></html>');
window._w.document.close();
}
else{
if(document.layers)
window._w.resizeTo(url.width,url.height);
else
window._w.resizeTo(url.width+25,url.height+60);
}
}
</script>
si noti l'uso di void o # |