[thelist] javascript/fer why?

Josué Figueira Machado jmachado at mindspring.com
Wed Feb 20 14:21:01 CST 2002


Try this:
(1) Put this in your script;

var newWindow = new Object();
newWindow = null;

function subWin(url,wdth,hght){
   var screenTop = (screen.height / 2) - (hght / 2);
   var screenLeft = (screen.width / 2) - (wdth / 2);
   if (newWindow && !newWindow.closed) {
        newWindow.close();
   }
   newWindow =
window.open(url,'newWin','width='+wdth+',height='+hght+',top='+screenTop+',left='+screenLeft+',screenY='+screenTop+',screenX='+screenLeft+',status=no,scrollbars=no,resizable=no');

   if(!newWindow.opener) {
        newWindow.opener = self;
   }
   newWindow.focus();
}

(2) Then call it;

<a href="javascript:subWin('digitalio/digitalio1.htm',500,375);">your image</a>

I changed the way you position the new window in the page, but let me know
if you wish to pass those values as well. Watch for the line wrapping and
let me know if it doesn't work. Good luck,

Josué

At 12:16 PM 2/20/2002 -0500, you wrote:
>hey everybody.
>
>I am NOT a javascript master, more like someone who can massage pre-written
>code. if you were to look at the source code here
>http://identfi.com/pleasure/photobody.shtml
>-warning old content-
>You will notice that I have ten billion subwindows being defined. What I'm
>looking for is a onetime .js reference in the head and an attribute
>definition in the <a href>. example
>
>function subWin1(){
>
>         window.open(.... thiswindow, thiswidth, this height, border...
>etc..)
>
>  THEN in the call <a href="javascript:subWin1(500,400,no,yes...etc);">
>
>that way I could define different sized popups not in the head but in the
>function call. dig me?
>
>There just has to be a way to make what I'm attempting easier (and
>lighter-kb), instead of just forcing all images/popups to the same size. am
>I crazy? is this possible?




More information about the thelist mailing list