Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I change the location of the popup window on the screen? 1

Status
Not open for further replies.

GirlFriday1

Programmer
May 1, 2001
20
CA
Hello! I need to know how to change the location of the popup form on the screen to locate itself at the top, right hand corner. Presently, it opens in the middle of the screen and the user must move the popup window manually. Any suggestions?
Thanks!
 
tested and works in IE5.5...not really sure if the -10 part will always work (this accounts for the border). The function returns a reference to the newly created window:

function openDockWindow(theurl,width,height)
{
var dockedwin;
dockedwin=window.open(theurl,"dockedwin","width="+width+",height="+height)
dockedwin.moveTo(screen.width-(width+10),0)
return dockedwin;
}
x=openDockWindow("about:hello",300,300)
x.focus() jared@eae.net -
 
Try using this function:

function NewWindow(mypage,myname,w,h,scroll){

winprops = 'height='+h+',width='+w+',top=0,left=0,scrollbars='+scroll+',resizable=no,toolbar=no,titlebar=no,alwaysRaised=yes,dependent=yes,hotkeys=no,menubar=no'
win = window.open(mypage, myname, winprops)
}

Where mypage is the url
myname is the name of the popup window
w= width
h=height
scroll is boolean

Hope this helps :)
 
mkay,,, I'm not sure how to implement these suggestions so I guess I'll start with jaredn.
See how I put your code into the function? Is that where to put it? If not, where?
Any suggestions?
Thanks!

<script language=&quot;javascript&quot;>
function openMe(){
DeptList = window.open(&quot;DeptList.asp?id=&quot;+document.DeptForm.User.value,&quot;DeptList&quot;,&quot;TOOLBAR=NO,MENUBAR=NO,LOCATION=YES,RESIZABLE=YES,SCROLLBARS=YES,WIDTH=450, HEIGHT=300&quot; width=&quot;+width+&quot;,height=&quot;+height);
DeptList.moveTo(screen.width-(width+10),0)

window.DeptForm.submit();
}
</script>
</head>
 
something like this:


function openDockWindow(theurl,winname,width,height,otherops)
{
var dockedwin;
otherops = otherops?&quot;,&quot;+otherops:&quot;&quot;
dockedwin=window.open(theurl,winname,&quot;width=&quot;+width+&quot;,height=&quot;+height+otherops)
dockedwin.moveTo(screen.width-(width+10),0)
return dockedwin;
}

DeptList = openDockWindow(&quot;DeptList.asp?id=&quot;+document.DeptForm.User.value,&quot;DeptList&quot;,450,300,&quot;TOOLBAR=NO,MENUBAR=NO,LOCATION=YES,RESIZABLE=YES,SCROLLBARS=YES&quot;);
jared@eae.net -
 
You may have to explain this like I'm an 8 year old. So in the 1st part of the function when you declare the dockedwin variable,

1) what does the otherops variable do?
2) In your explanation:
&quot;width=&quot;+width+&quot;,height=&quot;+height+otherops) Where do you specify the height and width? Is it something like
&quot;width=&quot;+450+&quot;,height=&quot;+510+otherops
or is it the other way around.
I'm just not sure where to declare the variables.
Thanks!
 
if you just copy and paste the following:

function openDockWindow(theurl,winname,width,height,otherops)
{
var dockedwin;
otherops = otherops?&quot;,&quot;+otherops:&quot;&quot;
dockedwin=window.open(theurl,winname,&quot;width=&quot;+width+&quot;,height=&quot;+height+otherops)
dockedwin.moveTo(screen.width-(width+10),0)
return dockedwin;
}

DeptList = openDockWindow(&quot;DeptList.asp?id=&quot;+document.DeptForm.User.value,&quot;DeptList&quot;,450,300,&quot;TOOLBAR=NO,MENUBAR=NO,LOCATION=YES,RESIZABLE=YES,SCROLLBARS=YES&quot;);

it should achieve the affect you are looking for. Basically, the openDockWindow is looking for the first parameter to be the url, the second to name of the window, the third the width, the fourth the height, and the fifth is any options besides height and width that you want to specify. jared@eae.net -
 
Yup, that is almost what I needed. I added another function to call the first one to get it to do exactly what I needed it to do. Here is the finished code in case you are interested!

<script language=&quot;javascript&quot;>
function GoNewWindow() {
openDockWindow('DeptList.asp?id='+document.DeptForm.User.value,'DeptList',325, 375,'TOOLBAR=NO,MENUBAR=NO,LOCATION=YES,RESIZABLE=YES,SCROLLBARS=YES');
}


function openDockWindow(theurl,winname,width,height,otherops)
{
var dockedwin;
otherops = otherops?&quot;,&quot;+otherops:&quot;&quot;
dockedwin=window.open(theurl,winname,&quot;width=&quot;+width+&quot;,height=&quot;+height+otherops)
dockedwin.moveTo(0,0)
return dockedwin;
}
</script>
It's that GoNewWindow function that makes everything snazzy. Thanks for all of your help!
 
I want to know how to get rid of OPENME
LOCKS up my windows me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top