# Code to put image url in clipboard



## soldier (May 11, 2002)

Hi,

Here's what I want the code to do: when I click on an image I want it to copy the URL of the image into the clipboard.
(The images are on my site.)
Thanx.


----------



## bassetman (Jun 7, 2001)

Just right click and copy location or copy shortcut!


----------



## soldier (May 11, 2002)

But isnt there a simpler way. Im too lazy to right click


----------



## brendandonhu (Jul 8, 2002)

Right Click>>Properties>>URL/Address
Too lazy to right click? What the hell could you possibly do on your computer if your too lazy to press one button? How many keys did you press to type your post?
Or are you trying to tell us you want to add the functionality to your website so users can click a button and get the URL?


----------



## soldier (May 11, 2002)

> _Originally posted by brendandonhu:_
> Or are you trying to tell us you want to add the functionality to your website so users can click a button and get the URL?


Yep thats right thats exactly what I want to do. Sorry if I wasnt clear enough.
I want the users to click on my image and get the URL put in their clipboard.


----------



## brendandonhu (Jul 8, 2002)

Ohh ok. Shoulda said that in the 1st place 
Only IE allows javascript to access the clipboard, so you could do something like set the address of the image to a variable. If the user is using IE, use execCommand to copy it to the clipboard, if they are not using IE, display the URL on the screen.


----------



## soldier (May 11, 2002)

Sorry Im not really experienced in javascript.

How would I set the address of the image as a variable?
Would it look something like this: 

var ADDRESS = document.image.src

How do I use execCommand?

Thank you for your patience and understanding.:up:


----------



## brendandonhu (Jul 8, 2002)

For some reason I keep writing little scripts that should work but dont 

Anyway-heres what I have, hope one of the JS experts can figure out why it isnt working.


```
[IMG]file.gif[/IMG]
```


----------

