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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup window positioning

Status
Not open for further replies.

meenu24

Programmer
May 5, 2006
37
US
Hi,

I am trying to write a javascript to create a popup window.
I am using struts framework and forwarding the request to a jsp and further populating details in JSP.
This is my script

function showpopup(setname)
{
//alert(setname);
window.open('<%=request.getContextPath()%>/showsetaffiliates.do?setname='+setname,'name','scrollbars=yes,resizable=yes,width=540,height=325');
}

Popup window opens, but gets displayed in some random location.
I want it to be displayed near the button I clicked. I searched in net and I did find ways for positioning it with respect to a browser window.
Is there a way to do it.

thanks

 
To position your popup window near the button that clicked it, you need to find the position of the button, and then add that information to the winopts string as
Code:
'scrollbars=yes,resizable=yes,width=540,height=325[red],top='+topPos+',left='+leftPos[/red]);
The trick is determining the topPos and leftPos since your page may scroll and the button might not always be at a specified location.

I use some of the excellent scripts from Matt Kruse [URL unfurl="true"]http://www.mattkruse.com/[/url] specifically the AnchorPosition.js for this. Take a look and see if you can find something that can help you.

Einstein47
There are no kangaroos in Austria!
[&#91;]Starbase47.com]
 
Thanks Einstein47
I searched through the site, I was not able to locate AnchorPosition.js. The site seems to be useful though.



 
In reading the legal stuff in the AnchorPosition.js file, I can see that Matt would rather you get scripts directly from his site. Sorry but - if we start stepping on one another's toes, then we ALL end up with hurt feel.

Good luck, though - if you do have something more specific, ask and I'll see if I can help.

Einstein47
There are no kangaroos in Austria!
[&#91;]Starbase47.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top