Pop-up enlarged image viewer

Author
Discussion

miniman

Original Poster:

25,956 posts

267 months

Thursday 13th May 2004
quotequote all
Does anyone have a bit of ASP code (has to be ASP, can't get my head around PHP) that will automatically resize a browser window to fit the image that is currently displayed in it?

I want to use it for pop-up full-size images that vary slightly in size from time to time.

Cheers all...

miniman

Original Poster:

25,956 posts

267 months

Thursday 13th May 2004
quotequote all
Yup! All I need is the ResizeToImg code!!

steve-p

1,448 posts

287 months

Thursday 13th May 2004
quotequote all
One thing about the web is that it's easy to steal other people's ideas:

www.tvrcc-northants.co.uk/scripts/nav.js

In javascript, at least. Server side technologies such as PHP and ASP can be trickier.

fatsteve

1,143 posts

282 months

Thursday 13th May 2004
quotequote all
miniman said:
Yup! All I need is the ResizeToImg code!!


Can do it with Javascript:

function resizeToImg(img) {
imgWidth = img.width;
imgHeight = img.height;

self.resizeTo(imgWidth,imgHeight);
self.moveTo((self.screen.width-imgWidth)/2,(self.screen.height-imgHeight)/2);
}

Simply call it OnLoad in the img tag
<img src="piccy.jpg" onLoad="resizeToImg(this);">

fatsteve

1,143 posts

282 months

Thursday 13th May 2004
quotequote all
steve-p said:
One thing about the web is that it's easy to steal other people's ideas:

<a href="http://www.tvrcc-northants.co.uk/scripts/nav.js">www.tvrcc-northants.co.uk/scripts/nav.js</a>

In javascript, at least. Server side technologies such as PHP and ASP can be trickier.



Oh yes, it's great because you always have examples that you or other people wrote to refer back to, an online box of tricks if you will.!
Steve

>> Edited by fatsteve on Thursday 13th May 13:18

miniman

Original Poster:

25,956 posts

267 months

Thursday 13th May 2004
quotequote all
Thanks guys, that's great. So how do I get rid of the toolbars / status bar etc???

fatsteve

1,143 posts

282 months

Thursday 13th May 2004
quotequote all
miniman said:
Thanks guys, that's great. So how do I get rid of the toolbars / status bar etc???


You do it in the window.open call, hence

function showImage(p_imageURL) {
x = window.open(p_imageURL,"windowName","toolbar=no");
}

<a href="javascript:showImage('/images/mypiccy.jpg');">click me</a>

The values in the last bit of the open window call are a comma separated list of parameters, eg "toolbar=no,menubar=no,status=no" etc

Steve

miniman

Original Poster:

25,956 posts

267 months

Thursday 13th May 2004
quotequote all


Many thanks...