Window Location(s)

H

Homer J.

I have a web page that has a popup that is opened via window.open. No
problems here. The web app that I'm writing will be used by folks that run
dual monitors. How can I have that popup open on the same monitor that the
parent is on?
 
S

S. Justin Gengo

Homer,

This may work for you - I found it in a post on another site:

You can't specify the monitor, but you can specify the position of the popup
window as being relative to the where the click caused the window to popup.

Use the getMouseXY() function to get values to pass as the left and top args
to the window.open() method. (the left and top args only work with V3 and up
browsers).

window.open docs: http://www.javascripter.net/faq/openinga.htm

function getMouseXY( e ) { if ( event.clientX ) { // Grab the x-y pos.s
if browser is IE. CurrentLeft = event.clientX +
document.body.scrollLeft; CurrentTop = event.clientY +
document.body.scrollTop; } else { // Grab the x-y pos.s if browser
isn't IE. CurrentLeft = e.pageX; CurrentTop = e.pageY; }
if ( CurrentLeft < 0 ) { CurrentLeft = 0; }; if ( CurrentTop < 0 ) {
CurrentTop = 0; }; return true;}

--
Sincerely,

S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
H

Homer J.

And this will work on an ASP.Net Web Page even though InitializeComponent
uses the System.Windows.Markup Namespace?
 
H

Homer J.

Justin,
would you be able to post the article link so I can read how this is
applied? I'm calling the window.open from C#. I'm not sure how I would
apply your example since I'm such a genius in Java.
 
H

Homer J.

Never mind...I found it. Ok, maybe this would be better.

I'm using the below code to open my window:

protected void ProjectGridView_SelectedIndexChanged(object sender,
EventArgs e)
{
try
{
Session["ProjID"] = ProjectGridView.SelectedValue.ToString();
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("window.open('DCNORG.aspx',
'','toolbar=0,height=275,width=450,resizable=0,scrollbars=0, Left=50,
top=120');");
sb.Append("</script>");
Page.RegisterStartupScript("test", sb.ToString());
}
catch (Exception ex)
{
ReportError(ex.Message);
}
}



This is all fine and dandy if there's only 1 monitor. I need to be able to
pass the mouse coordinates should the above be executed from Monitor 2. If
this has to be done in Java, I'm not sure how to apply it.

Sorry for the hassle. This is 1 of 2 first posts.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,406
Latest member
ElizabetMo

Latest Threads

Top