Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Modal window

  1. #1
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Modal window

    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!!

  • #2
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    This is what I use.

    Code:
    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.availHeight,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;
    	s+=(!f||f=='')?'':','+f;
    	var win=window.open((u)?u:'http://www.ericking.us/',(n)?n:'',s);
    	if(win && !win.closed){
    		win.focus();
    		return win;
    	}
    	if(!win)
    		document.location=u;
    }
    
    
    
    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),
    						"dialogHeight:"+h+"px",
    						"dialogWidth:"+w+"px",
    						"help:yes",
    						"resizable:"+(resizable==true?1:0),
    						"status:"+(status==true?1:0),
    						"scroll:"+(scroll==true?1:0),
    						"edge:raised"];
    	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){
    		win=window.showModelessDialog(u,n,mFeatures.join(';'));		
    	} else if("undefined"!=typeof window.showModalDialog){
    		win=window.showModalDialog(u,n,mFeatures.join(';'));
    	} else {
    		win=NewWindow(u,n,w,h,f+',modal=yes',p,x,y);	
    	}
    	return win;
    }
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •