Click to See Complete Forum and Search --> : I need help with this script..


soulflycrx
11-30-2002, 11:47 AM
I can't get this script to work...well, at least some of it.
I want to have a link to open an image in a pop-up style window. I want the window to be the exact same size as my photo. (IE. My image is 200x400, so I want the window to have the same viewing dimensions)

Here is the script. What is wrong? When I click my link, it DOES bring up a new window with my photograph in it, BUT the new window is not the same size as the photo. The new window is way to big.


<script language="javascript">
function popUp(filename,imageWidth,imageHeight) {
newWin =
window.open(filename,"myPic","width=imageWidth,height=ImageHeight,menubars=no,scrollbars=no,statusbar=no,locationbar=no");
}
</script>


and in the body...


click me (javascriptopUp('image.jpg',50,100);)

Zach Elfers
11-30-2002, 12:50 PM
<script language="javascript">
function popUp(filename,imageWidth,imageHeight) {
newWin =
window.open(filename,"myPic"," width=200,height=400,menubars=no,sc
rollbars=no,statusbar=no,locationbar=no");
newWin.document.write(image.jpg);
}
</script>

Then in the body put onClick="javascript: popUp();"

I think that will work.:)

Charles
11-30-2002, 01:20 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Window Example</title>
<script type="text/javascript">
<!--
function popUp (filename,imageWidth,imageHeight) {
geometry = 'height=' + imageHeight + ',width=' + imageWidth;
var newWin = window.open (filename, myPic, geometry);
return false;
};
// -->
</script>
<p><a href="image.png" onclick="return popUp (this.href, 50, 100)">Image.png</a></p>

soulflycrx
11-30-2002, 11:57 PM
Ok. here is what I tried. It did not work. All it did, was open a new window with my image in it. The window did not re-size itself to my image.


<html>
<head>
<title>My page</title>


<script type="text/javascript">
<!--
function popUp (filename,imageWidth,imageHeight) {
geometry = 'height=' + imageHeight + ',width=' + imageWidth;
var newWin = window.open (filename, myPic, geometry);
return false;
};
// -->
</script>


</head>

<body bgcolor="#FFFFFF" text="#000000">
<a href="images/file-ryan.jpg" onclick="return popUp (this.href, 95, 95)"><img src="images/file-corvus.jpg" width="95" height="95" border="0"></a>



Basically, I had an image on a website...like an icon lets say. I want to be able to click on that icon, and open an image in a pop up window, and have the window automatically rezise to the dimensions of my image.

soulflycrx
12-01-2002, 12:32 AM
NEVERMIND! I figured it out. Here is the link I used to do it...

http://www.crays.com/jsc/jsPImg.htm#popimg

Works wonderful!