Jojoxx.net logotyp

 

 

Användare ikonAnvändare
Besökare just nu: 57
Snabblänkar ikonSnabblänkar
JavaScript-arkivet
Perl
FAQ

Sök på Jojoxx.net


Popup-generator

Exempel

ULR (http-adress)
Namn
Storlek (bredd x höjd) x px
Position
x px
Egenskaper Verktygsfält (toolbar) Adressrad (location) Directories (directories)
Statusrad (status) Menyrad (menubar) Scroll-lista (scrollbars)
Skalbarhet (resizable)
Fönstret öppnas direkt
med en länk med texten
med en knapp med texten
 
 

Kod


<script type="text/javascript">
/*  The code contained in this  file is copyrighted by www.jojoxx.net
The file may be used for none commercial applications and distributed
as long as these lines remain intact.  The file or part of it may not
be sold  or  included  in any  other commercial  application  without
agreement from the author. If you have questions or comments, contact
the author at http://www.jojoxx.net

© Copyright - www.jojoxx.net - 2004                                */

function center(width,height,cx,cy){
	var x=(cx==0)?0:(cx==1)?parseInt((screen.width-width-10)/2):screen.width-width-10;
	var y=(cy==0)?0:(cy==1)?parseInt((screen.height-height-56)/2):screen.height-height-56;
	return (",top="+y+",left="+x);
}
function gencode(obj){
	var str='<script type="text/javascript">\n';
	str+="function center(width,height,cx,cy){\n";
	str+="\tvar x=(cx==0)?0:(cx==1)?parseInt((screen.width-width-10)/2):screen.width-width-10;\n";
	str+="\tvar y=(cy==0)?0:(cy==1)?parseInt((screen.height-height-56)/2):screen.height-height-56;\n\treturn (\",top=\"+y+\",left=\"+x);\n}\n";
	str+="function openwindow(url){ "+genWincode(obj)+" }\n";
	if(obj.openwith[0].checked){
		str+="openwindow('"+obj.url.value+"');\n";
	}
	str+='</scr'+'ipt>\n';
	if(obj.openwith[1].checked){
		str+='<a href="'+obj.url.value+'" onclick="openwindow(this.href); return false;">'+obj.linktext.value+'</a>';
	} else if(obj.openwith[2].checked) {
		str+='<form><input type="button" value="'+obj.buttontext.value+'" onclick="openwindow(\''+obj.url.value+'\');"></form>';
	}
	obj.code.value=str;
	return false;
}
function genWincode(obj){
	var features="";
	for(var n=0;n<obj.length;n++){
		if(obj[n].name=="feature"){ features+=(features)?",":""; features+=obj[n].value+"="+((obj[n].checked)?"yes":"no"); }
	}
	var width=((parseInt(obj.width.value)>100)?parseInt(obj.width.value):"100"); features+=",width="+width;
	var height=((parseInt(obj.height.value)>100)?parseInt(obj.height.value):"100"); features+=",height="+height;
	if(obj.position.selectedIndex==0){
		features+=",top="+((parseInt(obj.y.value)>0)?parseInt(obj.y.value):"0");
		features+=",left="+((parseInt(obj.x.value)>0)?parseInt(obj.x.value):"0");
	} else {
		var c=obj.position(obj.position.selectedIndex).value.split(",");
		features+="\"+center("+width+","+height+","+c[0]+","+c[1]+")+\"";
	}
	return('window.open(url,"'+obj.name.value+'","'+features+'");');
}
function test(obj){
	var code="var url=\""+obj.url.value+"\";\n"+genWincode(obj);
	eval(code);
}
</script>
<form onsubmit="return gencode(this);">
<table>
<tr><td>ULR (http-adress)</td><td><input type="text" name="url" value="http://www.jojoxx.net"></td></tr>
<tr><td>Namn</td><td><input type="text" name="name" value="myWin"></td></tr>
<tr><td>Storlek (bredd x höjd)</td><td><input type="text" name="width" value="200" style="width:40px;"> x <input type="text" name="height" value="200" style="width:40px;"> px</td></tr>
<tr><td>Position</td><td><select name="position" onchange="this.form.x.disabled=this.form.y.disabled=(this.selectedIndex>0);"><option>Absolut</option><option value="1,1">Mitten</option><option value="1,0">Topp</option><option value="1,2">Botten</option><option value="0,1">Vänster</option><option value="2,1">Höger</option><option value="0,0">Topp/Vänster</option><option value="2,0">Topp/Höger</option><option value="0,2">Botten/Vänster</option><option value="2,2">Botten/Höger</option></select><br/><input type="text" name="x" value="200" style="width:40px;"> x <input type="text" name="y" value="200" style="width:40px;"> px</td></tr>
<tr><td>Egenskaper</td>
	<td>
	<input type="checkbox" name="feature" value="toolbar"> Verktygsfält (toolbar)
	<input type="checkbox" name="feature" value="location"> Adressrad (location)
	<input type="checkbox" name="feature" value="directories"> Directories (directories)<br/>
	<input type="checkbox" name="feature" value="status"> Statusrad (status)
	<input type="checkbox" name="feature" value="menubar"> Menyrad (menubar)
	<input type="checkbox" name="feature" value="scrollbars"> Scroll-lista (scrollbars)<br/>
	<input type="checkbox" name="feature" value="resizable"> Skalbarhet (resizable)
	</td>
</tr>
<tr>
	<td>Fönstret öppnas</td>
	<td>
		<input type="radio" name="openwith" value="direct" checked="checked"> direkt<br/>
		<input type="radio" name="openwith" value="link"> med en länk med texten <input type="text" name="linktext"><br/>
		<input type="radio" name="openwith" value="button"> med en knapp med texten <input type="text" name="buttontext"><br/>
	</td>
</tr>
<tr><td> </td><td><input type="button" value="Generera" onclick="gencode(this.form);"> <input type="button" value="Testa" onclick="test(this.form);"></td></tr>
<tr><td> </td><td><textarea name="code" wrap="off" style="width:500px;height:300px;"></textarea></td></tr>
</table>
</form>

Kommentar

Använd scriptet för att enkelt skapa popupfönster som du kan bestämma utseende, funktion och position på.

,