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

x/y position of last popup

Postby siege on Mon Apr 23, 2007 6:27 am

Can you store the last known position of a popup to be used for the next window the user pops up form the parent? This is driving me nuts trying to get an answer on this. Ex: user clicks on a link in the parent, a window pop up, the user moves it to a different location on the screen, then requests a new popup from the parent, this new pop up is now opened in to that location :?:
Last edited by siege on Mon Apr 23, 2007 3:56 pm, edited 1 time in total.
siege
 
Posts: 31
Joined: Fri Apr 20, 2007 11:03 pm

Postby LucasZ21 on Mon Apr 23, 2007 3:08 pm

You can probabally do it...but it's not HTML.
Image
User avatar
LucasZ21
100+ Club
 
Posts: 195
Joined: Mon Feb 26, 2007 2:31 am
Location: Mansfield, OH

Postby siege on Mon Apr 23, 2007 3:57 pm

thanks. do you have any idea of what language I could use. i thought maybe JS but no one seems to be biting there?
siege
 
Posts: 31
Joined: Fri Apr 20, 2007 11:03 pm

Postby LucasZ21 on Mon Apr 23, 2007 4:59 pm

I dont really have any idea lol I just know it's not HTML
Image
User avatar
LucasZ21
100+ Club
 
Posts: 195
Joined: Mon Feb 26, 2007 2:31 am
Location: Mansfield, OH

Postby siege on Mon Apr 23, 2007 5:19 pm

ha ha.. i got ya.... well maybe someone else will know... have a good day
siege
 
Posts: 31
Joined: Fri Apr 20, 2007 11:03 pm

Postby mwa103 on Mon Apr 23, 2007 5:55 pm

Are you wanting to open a second popup window in the same location, or do you just want the link to open in the same window and not have the window move. If it is the latter of the two, that may be a bit easier to implement using JavaScript. Not sure how you would do it yet, but I'll do some research for you.

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

Postby mwa103 on Mon Apr 23, 2007 6:08 pm

Looks like it's not as hard to do it the first way after all. I found this page which shows script for opening a new window at the same location as a window that is open. Not sure what you would do about one that the user closed.

-Mike

http://www.faqts.com/knowledge_base/view.phtml/aid/2310/fid/124
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

Postby siege on Mon Apr 23, 2007 6:41 pm

I want the new popup to open in the same location that the last popup has been dragged to..... in some instances the user might have left it centered, but for most they drag it to a different location besides the default center. Now BNasically each successive popup 'pops up' in the user's desired location. If they close it (whether its the first or next couple) the variables x and y are stored. Again, I got the thing to center on first popup, but i cant figure out how to establish the above. Thanks for your help.
I do want each link to open in whther its the same or one of the same name that reloads the info is fine. I will be using the same 'windowName' for each link.
siege
 
Posts: 31
Joined: Fri Apr 20, 2007 11:03 pm

Postby mwa103 on Mon Apr 23, 2007 7:32 pm

The ideal way to do this would be to use the onMove function, but I couldn't get it to work. I was able to put something together that should work though. I used the onLoad & onUnload functions to call a method which reports back to the opening window the popup's current location. I couldn't find any way to detect when the window was moved, so I had to use the setTimeout method to check every 5 seconds to see if the window had moved. Also, when the popup is closed, the onUnload function calls the same method to update the x & y. Not sure if this is 100% what you want, but it's as close as I could get. Good luck.

-Mike

Opening window:
Code: Select all
<html>
<head>
<title>Popups</title>
<script type="text/javascript">
   var x=300;
   var y=200;
   var numWindows = 0;
   function updateXY(newx,newy)
   {
      x = newx;
      y = newy;
      alert(x + " x " + newy);
   }
   function openPopup(address)
   {
      open(address, 'testing'+numWindows, 'left=' + x + ',top=' + y + ',resizable=0,scrollbars=1,width=400,height=400');
      numWindows++;
   }
</script>
</head>
<body>
   <input type=button name=testButton onClick="openPopup('test.html')" />
</body>
</html>


test.html (the popup)
Code: Select all
<html>
<head>
<title>Testing</title>
<script type="text/javascript">
   var myX=0;
   var myY=0;
   function updatePos()
   {
      if (document.all) {
         var x = window.screenLeft;
         var y = window.screenTop;
      }
      else {
         var x = window.screenX;
         var y = window.screenY;
      }
      if(x!=myX || y!=myY)
      {
         window.opener.updateXY(x,y);
         myX=x;
         myY=y;
      }
      setTimeout("updatePos()", 5000);
   }
</script>
<body onLoad="updatePos()" onUnload="updatePos()">
   <h3>This is a test</h3>
</body>
</html>
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

so close

Postby siege on Mon Apr 23, 2007 11:02 pm

thank you so much so far for your help.... its close... the very first pop has to be centered, then the rest use your x/y functions.... heres what im using in replacement of your openPopup function, tell me, is there a way to turn my centering function off after it has been used the first time?
Code: Select all
[size=18]var win=null;
function popMe(mypage,myname,w,h,scroll,pos){
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}
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);}[/size]
siege
 
Posts: 31
Joined: Fri Apr 20, 2007 11:03 pm

Next

Who is online

Users browsing this forum: No registered users and 11 guests

cron