Salve a tutti da piero06 !
Rispondendo ad un pò di domande del forum, ho notato che sono ricorrenti le discussioni sulle finestre pop up di tutti i tipi ( in apertura, in chiusura al click ...).
Ho allora pensato di fare una pillola riassumento le pop up più comuni che si possono inserire nelle proprie pagine web per utilizzarle nei modi più svariatie al webmaster utili.
Le ho raggruppate non seguendo uno schema ben definito ma a seconda di come mi capiatavano in mano ! :gren:
Pop up in apertura dopo il Click
Nel <body> nella pagina :
codice:
<a href="#"
onClick="window.open ('pagina.html','newWin', 'scrollbars=no,status=no,resizable=no,top=100,left=150,width=500,height=250');">
clicca qui </a>
Pop up apertura e chiusura automatica
nel <head>
codice:
<script>
newwindow=window.open("popup.html","","top=200,left=200,width=350,height=200")
newwindow.creator=self</script>
nel <body>
codice:
<script language="JavaScript">
setTimeout('window.close()',3000);
</script>
Lancio di una pop up in automatico in uscita di sito
nel <head>
codice:
<script LANGUAGE="JavaScript">
<!-- Begin
function leave() {
window.open('pagina.html','','toolbar=no,menubar=no,location=yes,top=150,left=300,height=150,width=200');
}
// End -->
</script>
nel <body>
codice:
< body onUnload="leave()">
Pop up centrato con apertura al clik
nel <head>
codice:
<script language="JavaScript">
function ApriFinestra(str) {
larg=300;
alt=350;
toptop=(screen.height/2)-(alt/2);
leftleft=(screen.width/2)-(larg/2);
searchWin = window.open(str,'','top='+toptop+',left='+leftleft+',scrollbars=no,width='+larg+',height='+alt+',status=no,location=no,toolbar=no');
}
</script>
nel <body>
codice:
<a href="javascript:;"
onClick="ApriFinestra('popup1.html', '', 'width=300,height=350, status=no, scrollbars=no');">
<p align="center">PRIMO POPUP</a> </p>
Pop up che si ridimensiona all'immagine
nel <head>
codice:
<script LANGUAGE="JavaScript">
function PrevFoto(img){
foto1= new Image();
foto1.src=(img);
Controlla(img);
}
function Controlla(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
funzione="Controlla('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto(img){
largh=foto1.width+20;
altez=foto1.height+25;
stringa="width="+largh+",height="+altez;
finestra=window.open(img,"",stringa);
}
</script>
nel <body>
Pop up in apertura in ritardo
nel <head>
codice:
<script>
function popup()
{
setTimeout("window.open('pagina.html','newWin','scrollbars=no,status=no,resizable=no,top=100,left=150,width=500,height=250');",5000);
}
</script>
nel <body>
codice:
<body onload="popup()"
Pop up a tutto schermo al click
nel <body>
Pop up a pit stop ( parte da sinistra e si frema al centro della pagina
nal <head>
codice:
<script>
<!-- Beginning of JavaScript -
var popwindow
var popwindowwidth=200
var popwindowheight=200
var popwindowtop=200
var popwindowURL="popup.html"
var waitingtime=5
var pause=20
var step=40
var popwindowleft=-popwindowwidth-50
var marginright
var pagecenter
var timer
waitingtime= waitingtime*1000
function showWindow() {
popwindow = window.open(popwindowURL, "popwindow", "toolbar=no,width="+popwindowwidth+",height="+popwindowheight+",top="+popwindowtop+",left="+(-popwindowwidth)+"");
if (document.all) {
marginright = screen.width+50
}
if (document.layers) {
marginright = screen.width+50
}
pagecenter=Math.floor(marginright/2)-Math.floor(popwindowwidth/2)
movewindow()
}
function movewindow() {
if (popwindowleft<=pagecenter) {
popwindow.moveTo(popwindowleft,popwindowtop)
popwindowleft+=step
timer= setTimeout("movewindow()",pause)
}
else {
clearTimeout(timer)
timer= setTimeout("movewindow2()",waitingtime)
}
}
function movewindow2() {
if (popwindowleft<=marginright) {
popwindow.moveTo(popwindowleft,popwindowtop)
popwindowleft+=step
timer= setTimeout("movewindow2()",pause)
}
else {
clearTimeout(timer)
popwindow.close()
}
}
// -->
</script>
nel <body>
codice:
<body onLoad="showWindow()">
apertura prograssiva di una pop up al click
nel <body>
codice:
<script>
<!--
var winheight=100
var winsize=100
var x=5
function openwindow(thelocation){
temploc=thelocation
if (!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById)){
window.open(thelocation)
return
}
win2=window.open("","","scrollbars")
win2.moveTo(0,0)
win2.resizeTo(100,100)
go2()
}
function go2(){
if (winheight>=screen.availHeight-3)
x=0
win2.resizeBy(5,x)
winheight+=5
winsize+=5
if (winsize>=screen.width-5){
win2.location=temploc
winheight=100
winsize=100
x=5
return
}
setTimeout("go2()",50)
}
//-->
</script> </p>
<p align="center"><font size="3"><a href="javascript:openwindow('collegamento_1.html')">Apri
il primo collegamento</a> </p>
<p align="center"><a href="javascript:openwindow('collegamento_2.html')">Apri il secondo
collegamento</a> </p>
pop up a full screen al click
nel <head>
codice:
<script>
// Amazing Frameless Popup Window - Version I
// (C) 2000 www.CodeLifter.com
// Free for all users, but leave in this header
var windowW=240
var windowH=300
var windowX = 260
var windowY = 100
var urlPop = "popup.html"
var title = "Qui inserisci il nome del popup"
var autoclose = true
// ============================
// do not edit below this line
// ============================
s = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false
function openFrameless(){
if (beIE){
NFW = window.open("","popFrameless","fullscreen,"+s)
NFW.blur()
window.focus()
NFW.resizeTo(windowW,windowH)
NFW.moveTo(windowX,windowY)
var frameString=""+
"<html>"+
"<head>"+
"<title>"+title+"</title>"+
"</head>"+
"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
"<frame name='bottom' src='about:blank' scrolling='no'>"+
"</frameset>"+
"</html>"
NFW.document.open();
NFW.document.write(frameString)
NFW.document.close()
} else {
NFW=window.open(urlPop,"popFrameless","scrollbars,"+s)
NFW.blur()
window.focus()
NFW.resizeTo(windowW,windowH)
NFW.moveTo(windowX,windowY)
}
NFW.focus()
if (autoclose){
window.onunload = function(){NFW.close()}
}
}
</script>
nel <body>
codice:
<body onload="top.window.focus()" bgcolor="#D8F0FA">
dove vuoi
Queste sono le pop up che ho pensato siano le più comuni e utilizzate. Qualche codice lo ho fatto prendendo spunto da codici di asbafo.net e altri fatti da me e mio cugino!
Spero che questa pillola possa essere utile a qualcuno per la costruzione del suo sito o per migliorarlo
Per eventuali errori o spiegazioni sono sempre disponibile o su questo forum, o su icq o su windows messanger !
Arrivederci e alla prossima !