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

Help! A two-monitor problem with popups

Status
Not open for further replies.

Aranor

Technical User
Jun 30, 2008
2
0
0
FI
Hey, I'm need help. I have built an art gallery to my art site and I wrote a JavaScript program to open up a new window when picture thumbnails are clicked. Here's the code:

<script type="text/javascript">
<!--
// Open a popup window of specific size and in screen-centered position.
function openWindow(ppage, pwidth, pheight){
var popupX = (window.outerWidth - 17 - pwidth)/2;
var popupY = (window.outerHeight - pheight)/2;
open(ppage, "", "toolbar=No, menubar=No, location=No, scrollbars=No, resizable=No, status=No, width="+ pwidth +", height="+ pheight +", left="+ popupX +", top="+ popupY +"");
}
-->
</script>

It is accessed like this:
<a href="javascript:;" onclick="openWindow('popup1.html', 820, 507);">

So, that also calculates the popup's coordinates so that the window is always centered, no matter what size it is. It worked fine with everyone until a friend with two monitors tested it. The popup opens in the wrong monitor! It's supposed to open up in the same monitor that the browser is in. What can I do? Is there a way to fix it? For example, is it possible to access the parent window's coordinates? I'm not very experienced in JavaScript, but I've already tried everything I could find.
 
the pop up windows with JavaScript always open on the main display if there are two present.
the only thing to do is to try to move the window left or right and check its time if the move was successful and if not then calculate the offset of the browsers window and move the pop up window to a relative position.

There was someone that asked almost the same question on another forum and finally he solved it himself.

I'm posting the link without being sure if this is allowed on this forum.
My apologies if it is not allowed.


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Okay, thanks a lot! After extra research and effort I decided to solve the issue by removing the calculation altogether. I let the browsers open the popups wherever they please. Now it works with dual monitors and somewhat okay overall. This is an acceptable compromise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top