[thelist] IE popup windows

.jeff jeff at members.evolt.org
Wed Jan 23 15:46:25 CST 2002


keith,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Keith
>
> That's called a chromeless window. [...]
>
> Most of the scripts I've seen for this effect fail to
> understand just how simple this really is. Basically
> you open an IE window to fullscreen, then IMMEDIATLY
> resize and reposition the window with a document.write,
> [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

whoooooooooooooa there bessy!  you reposition with a what?  writing script
to the new window is completely pointless and unnecessary.  when you created
the window you should already have a handle to it.  not only will it be much
cleaner to do the resizing and moving of the window from the function that
called it, but it'll happen much quicker (usually only seeming like a quick
flash as the window is resized from fullscreen).

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> function launch(url,wid,hei){
> if(document.all){
> win=window.open("","CM","fullscreen")
> win.document.open()
> win.document.write('<html><body>'+
> '<script>resizeTo('+wid+','+hei+');'+
> 'LeftPos=(screen.width-'+wid+')/2;'+
> 'TopPos=(screen.height-'+hei+')/2;'+
> 'moveTo(LeftPos,TopPos);'+
> 'window.focus();'+
> 'location="'+url+'"</scr'+'ipt>'+
> '</body></html>')
> win.document.close()
> }else{
> win=window.open(url,"CM","status=0,width="+wid+",height="+hei)
> }
> }
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

the check for document.all is unnecessary as browsers that don't support the
fullscreen attribute will simply ignore it.

so, taking these two things into consideration, here's how the function
should be written:

function launch(url,wid,hei)
{
  features = 'fullscreen,width=' + wid + ',height=' + hei;
  win = window.open(url, 'CM', features);
  if(win.resizeTo) win.resizeTo(wid, hei);
  if(win.moveTo)
  {
    leftPos = (screen.width - wid) / 2;
    topPos = (screen.height - hei) / 2;
    win.moveTo(leftPos, topPos);
  }
  if(win.focus) win.focus();
}

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> <a href=javascript:launch("pop.html","400","300")
> >here</a>
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

tsk, tsk. no quotes around attribute values?  links that aren't accessible
to non-js users? how naughty and unnecessary.  try this instead:

<a href="pop.html"
 onclick="launch(this.href, '400', '300'); return false"
>here</a>

now the non-js user can get at the content as well.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> OK, that gets the chromeless open, BUT that's when your
> work begins. Since a chromeless has no titlebar you need
> to create an obvious way for the user to close the
> window with window.close() [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

absolutely.  most users won't know to use ctrl+w, alt+f4, or right-clicking
the window's entry in the task bar and selecting "close" from the context
menu.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> [...] and preferably a titlebar so they can grab the
> window and move it.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

when it comes to window resizing and window dragging, look no further than
the work of erik arvidsson at webfx:

http://webfx.eae.net/dhtml/wincontrols/wincontrols.html

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> All that syntax needs to of course be on the page being
> loaded, and ignored by NN4 which will have a title bar.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

actually, by all but ie browsers as they'll all produce a titlebar.

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/






More information about the thelist mailing list