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.
<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.