ASP.NET - Find image middle point get x,y

Izi

Izi

Soldato
Joined
9 Dec 2007
Posts
2,718
I have thumb images which are a max of 100x100pxs.

I want to be able to find the middle point of the image and add 25px to top and bottom, getting something like this:

20444770.jpg


I then want to get the x and y of the top left corner so i can do:

<div style="background-position: x,y">Centered image here</div>

Any help would be mucho appreciated. deadline tomorrow :( ahhh.
 
Well if you can get the top,left you can then get the centre.

Code:
<html>
<head>
<script>

var d = document;

function getCoor(image) {
	var x = (document.layers) ? image.x : image.offsetLeft;
	var y = (document.layers) ? image.y : image.offsetTop;
	alert(x + "," + y);

}

</script>
</head>
<body><BR>
some text in front of image
<img id="test1" width="100" height="100" src="img1.jpg"></img>
<BR><BR><BR>

<input type="button" onclick="getCoor(document.getElementById('test1'))" id="btn" value="test"></input>
</body>
</html>

Meh didn't read the asp.net bit!

If it's an image button you can use the ImageClickEventArgs of the image_click event wich gives you e.x and e.y.
 
Last edited:
Back
Top Bottom