View Full Version : open image in new window
jrmillikan
7-4-02, 12:32 AM
I have links to images running through some of my paragraphs of text. For instance, "My dog was in his house in the backyard during the rainstorm"
I want the words dog and house to be hyperlinks that open an image of those items when clicked... but I want the image in a new window the size of the image rather than the entire page of text disappearing just to show one little picture on a blank white page with no navigation, etc. And I don't want to have to build a new html document for each and every picture.
Do-able?
alphadesk
7-4-02, 12:40 AM
Sure,
You can do it with a little javascript. Here is a link that will show you how to do just what you want. Just read the and follow the instructions.
http://javascript.internet.com/page-details/auto-resizable-pop-up.html
jrmillikan
7-4-02, 12:48 AM
thanks... that's better than nothing...
but if I understand correctly, that opens a new window of a standard size -- as written 1/2 screen width x 1/2 screen size -- customizeable at the top of every HTML document.
What if I wanted the pop up window to be the exact dimension of each individual image portrayed in it. They're simple .jpeg images but they're all different dimensions. I want the pop up window to act like a picture frame of sorts.
alphadesk
7-4-02, 12:51 AM
Try the link now. A different script. This one will open a popup that will size itself to what ever the size of the pic.
jrmillikan
7-4-02, 12:53 AM
awesome..... thanks man, it works like a champ!
Is there anyway I could get you to look at my test page and tell me why it didn't work for me. I'm new at this and if I could get it figured out it would give me another project to tackle.:)
Thanks,
Pete
http://www.coreattitude.com/album1.htm
alphadesk
7-4-02, 07:55 AM
The link "href" is looking for a .gif file. I see your thumbs are .jpg. Is the large pics actully .jpg? Is so change the reference from "lg1-.gif" to "lg1.jpg and see if it will work.
<a href="javascript:CaricaFoto('/img/auto-resizable-pop-up/lg-1.gif')" border="0" target="_blank">
<img src="Albums/LBJetSki/My%20Files0001.jpg" width="146" height="89" border="0"></a>
No go, I still get a blank full size page.
Any ideas?
Pete
alphadesk
7-4-02, 08:32 AM
Is the large pic in the htdoc folder or in several sub folders as the thumb? If so try putting the large pic in the htdocs folder. Maybe a path problem and make sure they are named correct.
Here's a pretty simple popup window. I've used it to render native .gif, .jpg, most any image format but I generally render html to control the presentation background. The <a, width, height..., specification line should by contiguous but the dummy href= can be on a separate line.
<a class=small onclick=window.open('yourfolder/your.html','','width=nnn,height=nnn,scrollbars=yes ,resizable=yes,location=no,menubar=no,toolbar=no,t op=0,left=0')
href="javascript:void(0)">YOUR CKICK ME TEXT or Image</a>
Your can see it in action at http://www.the-ebiz.net/PowerPointSkins - right click and look for window.open
Here is some simple JavaScript that I use on my sites to handle this sort of thing. I auctually use this code to support clickable thumbnail images as a link to a pop-up window containing the full-size image, with an appropriately sized and centered window. To impliment this code, you need to call the Javascript function zoomLink() with the following parameters for each clickable link:
thumb: URL to the thumbnail image file - can be absolute or relative
tWidth and tHeight: the width and height of the thumbnail image
bigPict: URL to the large image file - again, this can be absolute or relative.
bigWidth and bigHeight: the width and height of the large image
The JavaScript is as follows:
<!--
// test for advanced browsers
var ns4 = false;
var ns6 = false;
var ie4 = false;
if (document.layers) { ns4 = true; }
if (document.all) { ie4 = true; }
if (document.getElementById && !document.all) { ns6 = true; }
function zoomLink(thumb, tWidth, tHeight, bigPict, bigWidth, bigHeight) {
zRef = "<A HREF=\"javascript:popZoom('" + bigPict + "', " +
bigWidth + ", " + bigHeight + ")\">";
document.write(zRef + "<IMG SRC=\"" + thumb + "\" " +
"WIDTH=\"" + tWidth + "\" HEIGHT=\"" + tHeight + "\" " +
" ALT=\"Click Here for larger image\"></A>\n");
}
var aw = 640; // arbitrary default screen width - sort of assumes if the browser
// is that old, the computer might be old, too!
if ((ns4) || (ns6)) { aw = window.innerWidth; }
if (ie4) { aw = screen.availWidth; }
function popZoom(pictURL, pWidth, pHeight) {
var sWidth = aw;
var x1 = pWidth+10;
var y1 = pHeight+10;
var pZoomStr = "height=" + y1 + ",width=" + x1 + ",left=" + ((sWidth-x1)/2) +
",top=60,scrollbars=0,menubar=0";
pZoom = window.open("","", pZoomStr);
pZoom.document.open();
pZoom.document.writeln("<HTML><BODY BGCOLOR=\"skyblue\"" +
" onBlur='self.close();'>\n");
pZoom.document.writeln("<IMG SRC=\"" + pictURL + "\" WIDTH=\"" +
pWidth + "\" HEIGHT=\"" + pHeight + "\">");
pZoom.document.writeln("</BODY></HTML>");
pZoom.document.close();
} // end popZoom
// -->
Note the pop-up has an onBlur function to close itself automatically if the user clicks outside the window. You might want to remove that. Its a tough call. I like it because it reduces inadvertant desktop clutter for novices, but UI purists wouldn't like the magic disappearance of the window. Anyhoo, I hope it helps.
Richard L. Trethewey
www.rainbo.net
Wow, that is some great info! Now I have a few more ways to stay confused...ahhh...I mean busy.;) Thanks for the replies, I will put some seat time in and see what works best for me.
Thanks again,
Pete
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.