Click to See Complete Forum and Search --> : Pop up window to the right


rachums
06-26-2003, 10:37 AM
Hi, I am new to this and am having problems with my script. What I have is a script that opens an image sized window. It works nicely for me BUT I want the new window to be oriented on the right of the screen, centered horizontally. I have tried to just muddle my way through but alas, I have gotten nowhere. If someone could please lend their knowledge to my project, I would very much appreciate it.

Here is the script:
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
function showpic(url){
var newImg = document.createElement("img");
newImg.setAttribute("src",url);
//create image sized window
var winProps = "width="+newImg.width+", height="+newImg.height+", scrollbars=no, toolbar=no, directories=no, menu bar=no, resizable=yes, status=yes";
newwindow=open(url,"Picture",winProps);
}
</SCRIPT>

Thanks,
Rachael

Greelmo
06-26-2003, 11:21 AM
I believe that there is a javascript command that looks like this...
window.moveTo(x, y);

have that in the new window and run it onLoad

pyro
06-26-2003, 11:32 AM
You could easily modify this code to do that for you: http://www.infinitypages.com/research/centeredpopup.htm

SlankenOgen
06-26-2003, 11:58 AM
var wt = screen.availWidth;
var imgWt = newImg.width;
var imgHt = newImg.height;
var leftPos = wt - imgWt;

var winProps = "width="+imgWt+", height="+imgHt+", left = "+leftPos+", scrollbars=no, toolbar=no, directories=no, menu bar=no, resizable=yes, status=yes";

~mgb

rachums
06-26-2003, 04:40 PM
Thanks, I used SlankenOgen's solution and the window is now opening to the right. But, I have another snag. When the link is clicked, the pop up window opens the first time as this tiny little thing, not image sized, its a few px. BUT when I close the window and click the link again, the pop up is a properly sized window. What could cause this? Any ideas? Thanks for all the suggestions!
-Rachael

SlankenOgen
06-27-2003, 05:39 AM
Can you post a url where I can see it?

You could also add

Picture.resizeTo(imgWt, imgHt);
Picture.moveTo(leftPos, 0);

~mgb

rachums
06-27-2003, 12:47 PM
the page is not online and I don't have any place to put it online at the moment. I am working in Dreamweaver on Mac and "previewing" the page in IE 5. Could it be an issue with my system?
Thanks,
Rachael

SlankenOgen
06-27-2003, 01:31 PM
You will need to test it online to know for sure.

rachums
06-28-2003, 04:54 PM
Thanks, I'll probably be back when it is online!
-Rachael