PDA

View Full Version : Linking to an image & chosing a background color


Tombo
11-13-2002, 05:09 PM
Hullo,

Say you have a regular link to an image. When you click the link, the image is opened in the same browser window, aligned to the top left, with a white background and margins of 10 all around.

What I'm hoping to do: provide settings for this "default white page" that contains the image.

For example, when the link is clicked and the image is displayed, the page it's shown on has a back background, the image appears in the center of the page (most likely using a table), and there are no margins all around.

I currently have a pop-up image script I've modified and have been using for a while. I was wondering if there was a way to modify it so that the image would not open in a pop-up window (which is what the script does).

(The script also adds a title to the pop-up-window, along with a comment at the bottom of the image. The comment I would like to keep for the new modified script.)

The script:

Head Section:

<script>
<!--
function popimage(imagesrc,winwidth,winheight,imgdesc){
var look='width='+winwidth+',height='+winheight+','
popwin=window.open("","",look)
popwin.document.open()
popwin.document.write('<title>Page Title</title><body bgcolor="#000000" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"><img src="'+imagesrc+'"><br><table border="0" cellpadding="5" cellspacing="0" width="100%"><tr><td width="100%" align="left"><font face="verdana" size="1" color="ffffff">'+imgdesc+'</font></td></tr></table></body>')
popwin.document.close()
}
//-->
</script>

Body Section (actual link):

<a href="" onClick="popimage('img.jpg',512,384,'Image Comment.');return false">link</a>

So, if that script could be modified, great. If not, great too. I'm just hoping for something that would get the job done. (A script that works the same way, with similar properties in the a href tag, would be nice. :D )

(By the way, the script will be used with a frame set. I'll have one frame on the side with thumbnails, and one larger frome to show the picture. As the thumbnail is clicked, the image will apear in the larger frame, centered, with a black background, and possibly a comment at the bottom.)

Thanks

cg9com
11-13-2002, 05:44 PM
as long as you are linking to an actual picture file you cannot customize the window its shown in.

i believe the browser needs a file extension that will support the markup language.

why not just create a page for yor picture?

Tombo
11-13-2002, 05:49 PM
I'm dealing with over 100 thumbnails, so I'd rather not have 100 pages. :P

The script I posted open s a pop-up window with a "template" setting. (ie. black background, comment at bottom)

I was just wondering if instead of having that script open a new window, it would open a window in the browser, like a regular link. Then I could make that link go to another frame, and create a "template" page for every image viewed.

Tombo
11-13-2002, 06:00 PM
Okay, I think I've got it figured out, but I just want to make sure I'm not forgetting anything else here:

Head Script:

<script>
<!--
function showimage(imagesrc){
document.open()
document.write('<title>Online Photo Album</title><body bgcolor="#000000" topmargin="10" leftmargin="10" rightmargin="0" bottommargin="0" marginheight="10" marginwidth="10"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td width="100%" height="100%" align="center" valign="middle"><img src="'+imagesrc+'"></td></tr></table></body>')
document.close()
}
//-->
</script>

Body Scrit (link tag):

<a href="" onClick="showimage('image.jpg');return false">link</a>

It seems to work... but just to make sure before I start using it, are there any code errors?

Tombo
11-13-2002, 06:17 PM
Okay, here's the real problem now... how do I modify that script I provided above, the newest one that I modified, so that the page that it generates open sin a frame called "photos"?