There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware missing monitor network networking outlook outlook 2003 outlook 2007 outlook express password popups problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Code to put image url in clipboard


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
soldier's Avatar
Senior Member with 223 posts.
 
Join Date: May 2002
23-Jun-2003, 01:35 AM #1
Code to put image url in clipboard
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's Avatar
Computer Specs
Moderator with 45,882 posts.
 
Join Date: Jun 2001
Location: Great White North (WI)
Experience: Getting somewhere I hope
23-Jun-2003, 01:40 AM #2
Just right click and copy location or copy shortcut!
soldier's Avatar
Senior Member with 223 posts.
 
Join Date: May 2002
23-Jun-2003, 06:31 PM #3
But isnt there a simpler way. Im too lazy to right click
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
23-Jun-2003, 07:49 PM #4
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?
__________________
-Brendan
soldier's Avatar
Senior Member with 223 posts.
 
Join Date: May 2002
23-Jun-2003, 08:26 PM #5
Quote:
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's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
23-Jun-2003, 08:44 PM #6
Ohh ok. Shoulda said that in the 1st place :P
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.
__________________
-Brendan
soldier's Avatar
Senior Member with 223 posts.
 
Join Date: May 2002
25-Jun-2003, 12:17 AM #7
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.
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
28-Jun-2003, 01:29 PM #8
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.

PHP Code:
<img src="file.gif" onclick="srcCopy(this)">
<
script language="javascript">
function 
srcCopy(img)
{
var 
src img.src;
src.execCommand("Copy")
}
</script> 
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:25 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.