It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

x/y position of last popup

Postby mwa103 on Tue Apr 24, 2007 12:41 am

You could try setting a flag variable to signify whether or not you have opened one already. Something like:

Code: Select all
var win=null;
var openedYet=false;
function popMe(mypage,myname,w,h,scroll,pos){
if(!openedYet){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
openedYet=true;
}
else{
    x=newX;
    y=newY;
}
settings='width='+w+',height='+h+',top='+y+',left='+x+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';

win=window.open(mypage,myname,settings);}

Where newX & newY would be the x & y from my previous post.
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

Postby siege on Wed Apr 25, 2007 12:34 am

This seemed to work, just right. Thanks for your help. :D
I would like to use my variable 'myname' to set the popup to focus()... in my example I am setting the wrong window (the parent) to be on top. In flash I would do this like _root[myname].focus(); whats the equivilant in JS? I am using XHTML and I cannot put onBlur in the body tag of the test.html b/c it seems that is not allowed.

Code: Select all
var win=null;
var openedYet=false;
function popMe(mypage,myname,w,h,scroll,pos){
   alert ("area 0");
   if(!openedYet){
    alert ("area 1");
      if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
      if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
      else if((pos!="center" && pos!="random") || pos==null){
         LeftPosition=50;
         TopPosition=50;
          alert ("area 2: Did not specify correct position  or gave no position");
      }
      openedYet=true;
      }else{
       LeftPosition=x;
       TopPosition=y;
        alert ("area 3: feeding local var the root var");
   }
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
alert ("area 4");
win=window.open(mypage,myname,settings);
myname.focus();
}
siege
 
Posts: 31
Joined: Fri Apr 20, 2007 11:03 pm

Postby mwa103 on Wed Apr 25, 2007 3:43 pm

Not completely sure, but I think you want to use the win variable instead of the name. The win variable references the popup window so you should be able to put it:
Code: Select all
win.focus()


Here is a link to a page on quirksmode.org that talks about focus & popup controls. Good luck.

-Mike
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

Postby siege on Wed Apr 25, 2007 3:48 pm

thanks for all your help. See you around.
siege
 
Posts: 31
Joined: Fri Apr 20, 2007 11:03 pm

Previous

Who is online

Users browsing this forum: No registered users and 10 guests