View Full Version : Modal window

12-16-2005, 05:00 PM
Hi y'all!!

I'd like to know if there's a way to invoke a modal window, that is a window that make impossible for the parent to get the focus, and returns back to the opener a value.

My goal is to make an anchor that opens another (little) win with a representation of the remote content in a personal directory on the server. Once you click on a file, it makes the parent window display its name into a form.

If I did not want to generate this filesytem representation, maybe a simple "prompt" could satisfy my request... but I need something more, so I'd like to extend this concept customizing the return-value-text-field!!

Thanx in advance guys!!

12-16-2005, 05:52 PM
This is what I use.

function NewWindow(u,n,w,h,f,p,x,y){
/* Copyright Eric King : http://www.ericking.us/ - © 2000 - 2005
This script is free to use for any non profit website as long as this info is left in */
var ws=window.screen?1:0,m=Math,C='center',R='random',M='custom',sw=screen.availWidth,sh=screen.availHei ght,w=(w)?w:sw,h=(h)?h:sh,T=(p==C&&ws||!p)?(sh-h)/2:(p==R&&ws)?(m.floor(m.random()*(sh-h))):(p==M&&h!=sh)?y:0,L=(p==C&&ws||!p)?(sw-w)/2:(p==R&&ws)?(m.floor(m.random()*(sw-w))):(p==M&&w!=sw)?x:0,s='width='+w+',height='+h+',top='+T+',screeny='+T+',left='+L+',screenx='+L;
var win=window.open((u)?u:'http://www.ericking.us/',(n)?n:'',s);
if(win && !win.closed){
return win;

function modalWindow(u,n,w,h,f,p,x,y){
var win = null;
var resizable = (f!=null)?/resizable/.test(f):false;
var status = (f!=null)?/status/.test(f):false;
var scroll = (f!=null)?/scroll/.test(f):false;
var mFeatures = [ "center:"+(p.toLowerCase()=="center"?1:0),
if(x!=null && mFeatures[0]==1)mFeatures.push("dialogLeft:"+x+"px");
if(y!=null && mFeatures[0]==1)mFeatures.push("dialogTop:"+y+"px");

if("undefined"!=typeof window.showModelessDialog){
} else if("undefined"!=typeof window.showModalDialog){
} else {
return win;