PDA

View Full Version : Click on image and get the URL for it?


RetroGamer1991
03-03-2002, 06:41 PM
when I click on a image, i'd like to get the full URL for it
example:
http://www.htmlforums.com/somefolder/whatever.gif

I know i'd have to use the onClick function, but how do i get the URL for the image (this needs to be dynamic, so i can just add the onClick=getURL() function and get it

Thanks

Jon Hanlon
03-03-2002, 08:32 PM
All you need is the .src property of the image.

<img src="..." onclick="getURL(this)">

<script>
function getURL(pic) {
alert("URL is " + pic.src)
}
</script>