Mouse Click Effect

G

gcc

What I want to do is put a bunch of images on a page for use in php forum
boards, I will be hosting the images for forum users to post as avatars

I want the user to be able to go to the Image page, Click the picture and
have the url to that picture appear in a text box directly below that
picture with a "Copy" button next to it that copys the url to the users
clipboard.

Pretty basic i know, But i am still a beginner

TIA
 
J

Jeffrey Silverman

What I want to do is put a bunch of images on a page for use in php forum
boards, I will be hosting the images for forum users to post as avatars

I want the user to be able to go to the Image page, Click the picture and
have the url to that picture appear in a text box directly below that
picture with a "Copy" button next to it that copys the url to the users
clipboard.

Pretty basic i know, But i am still a beginner

TIA

Use these pieces, not necessarily in this order:

[1] onClick() method
[2] document.getElementById('whatever').value to change the value of the
text input (example: <input type="text" id="whatever">)
[3} make sure to give all the relevant pieces id's. (example: <div
id="imagethumb">
[4] a PHP array of the image, image name, and/or image URL that you will
loop over and print out the relevant bits.

Putting the pieces together is for you to figure out. If you get stuck,
let me know.

I'm not so certain you can copy stuff to a "clipboard" memory space using
JavaScript, though. In fact, I'm pretty sure you can't. (At least, you
*shouldn't* be able to access a "clipboard" memory space with JavaScript
for security reasons).
 
S

Steve Pugh

I'm not so certain you can copy stuff to a "clipboard" memory space using
JavaScript, though. In fact, I'm pretty sure you can't. (At least, you
*shouldn't* be able to access a "clipboard" memory space with JavaScript
for security reasons).

So guess which browser lets you do just that?

Steve
 
J

Jeffrey Silverman

(At least, you

So guess which browser lets you do just that?

Steve

I'm gonna guess MSIE. Is it JavaScript or ActiveX that lets you do this,
though?
 
S

Steve Pugh

I'm gonna guess MSIE. Is it JavaScript or ActiveX that lets you do this,
though?

Yep, MSIE. JavaScript I think. I don't know the details 'cos I've never
had any need or desire to so such a thing. But people keep on posting on
the Opera newsgroups asking why Opera doesn't support this.

Steve
 
D

David Dorward

Mitja said:

Two paragraphs after telling me that clicking the button would copy text to
my clipboard, then telling me it needs IE 4.0 or better it contradicts
itself by saying it will ONLY work in IE (So it won't work in my browser,
and it won't work in the better-then-IE-4.0 browser that I use).

It then goes on to the truly delightful bit of CSS which attempts to use the
height and width properties on a span (without making it a block) where
they don't apply, and giving them non-zero lengths without units (which
browsers should ignore).

Looks like "Joe Burns, Ph.D." is as good at writing about webpage authoring
as ever.
 
L

Lenny Linux

TRY-----this for copy to clipboard from the form - [getit] - and -
[picurl] - textbox --textbox is locked from character entering by users.

<form name="getit">
<INPUT TYPE="TEXT" NAME="picurl" size="28" onFocus="this.blur()">
<INPUT TYPE="BUTTON" VALUE="Copy To Clipboard"
onClick="document.getit.picurl.select(); document.execCommand('Copy');">
</form>
 
R

rf

Lenny said:
TRY-----this for copy to clipboard from the form - [getit] - and -
[picurl] - textbox --textbox is locked from character entering by users.

<form name="getit">
<INPUT TYPE="TEXT" NAME="picurl" size="28" onFocus="this.blur()">
<INPUT TYPE="BUTTON" VALUE="Copy To Clipboard"
onClick="document.getit.picurl.select(); document.execCommand('Copy');">
</form>

Could you provide an example page where this works please?
 
L

Lenny Linux

Copy and paste the code below into notepad and save as - copyit.htm - on
your desktop.

Than open the webpage copyit.htm and hit the copy button. open notepad and
right click to paste text.



<html>
<head>
<title>testit</title>
</head>
<body bgcolor="0000ff">
<form name="getit">
<INPUT TYPE="TEXT" NAME="picurl" size="28" value="this text box"
onFocus="this.blur()">
<INPUT TYPE="BUTTON" VALUE="Copy To Clipboard"
onClick="document.getit.picurl.select(); document.execCommand('Copy');">
</form>
</body>
</html>





rf said:
Lenny said:
TRY-----this for copy to clipboard from the form - [getit] - and -
[picurl] - textbox --textbox is locked from character entering by users.

<form name="getit">
<INPUT TYPE="TEXT" NAME="picurl" size="28" onFocus="this.blur()">
<INPUT TYPE="BUTTON" VALUE="Copy To Clipboard"
onClick="document.getit.picurl.select(); document.execCommand('Copy');">
</form>

Could you provide an example page where this works please?
 
R

rf

Lenny Linux wrote:

[top posting fixed]

Largely nitpicking but:
<INPUT TYPE="TEXT" NAME="picurl" size="28" value="this text box"

There is a little bit of difference between this example and the prior one,
is there not :)

Suddenly we have something *in* the input element.
onFocus="this.blur()">

This does *not* make the input element read only. It only stops keyboard
entry. Does not stop cut/copy/paste. If you want a read only input element
then use the readonly attribute.
onClick="document.getit.picurl.select(); document.execCommand('Copy');">

You forgot to mention that execCommand is a microsoft only method and so is
rather useless in a web context. I wonder if IE SP2 still supports this.
 
D

David Dorward

This does *not* make the input element read only.

It also causes the browser to throw away the focus whenever it hits the
element. When nothing has the focus, the next item in sequence is the
first. This makes going backwards the only way that a user using a
non-pointing device can get to elements after the focus thrower. If two
elements have this, then any between them are entirely in accessible.

Blue elements on focus is very very harmful as regards accessability. Don't
do it!
 
D

David Dorward

This does *not* make the input element read only.

It also causes the browser to throw away the focus whenever it hits the
element. When nothing has the focus, the next item in sequence is the
first. This makes going backwards the only way that a user using a
non-pointing device can get to elements after the focus thrower. If two
elements have this, then any between them are entirely in accessible.

Bluring elements on focus is very very harmful as regards accessability.
Don't do it!
 
M

Mitja

Two paragraphs after telling me that clicking the button would copy text
to
my clipboard, then telling me it needs IE 4.0 or better it contradicts
itself by saying it will ONLY work in IE (So it won't work in my browser,
and it won't work in the better-then-IE-4.0 browser that I use).
It then goes on to the truly delightful bit of CSS which attempts to use
the
height and width properties on a span (without making it a block) where
they don't apply, and giving them non-zero lengths without units (which
browsers should ignore).
Wow, that _is_ cool. I only glanced at the JS code, read that clipboard
manipulation is indeed possible with IE, and closed the window.
Looks like "Joe Burns, Ph.D." is as good at writing about webpage
authoring as ever.
:) I have my private opinion of people that tend to sign everything with
their full title anyway, but this is rightout funny.
 
L

Lenny Linux

So produce a solution for the original question asked.

I presented a possible solution with the word -- TRY -- not explicitly do
this.

The scenario showed how an input type could get a textbox filled and how to
copy to the clipboard.

Perhaps with what knowledge you have, show how the question can be coded and
not bomb the possiblities from others.

And this goes for all newsgroup know it alls who like to swing it and have a
shortage of noodles in there heads who can't produce an answer but will jump
those who try.


Regards,



Dr. Mysterian - in the wild....... Producer of autonomous things and general
thought processes for the benefit of all mankind.
 
D

David Dorward

Lenny said:
So produce a solution for the original question asked.

My knowledge of the Microsoft propriety objects in JavaScript combined with
my ability to test in IE on my own time is not good enough to create a good
solution to the original question. However, it is good enough to recognise
the hideous flaws in your solution.
I presented a possible solution with the word -- TRY -- not explicitly do
this.

So you were unable to recognise the problems with it. Why complain when
other people can?

By the way, top posting is heavily frowned upon in this newsgroup.
http://www.allmyfaqs.com/faq.pl?How_to_post
 
M

Mitja

It is nitpicking, but the text is perpetuating the myth that IE is the
best browser out there - something that gets right up my wick.
That you have the right to. I was merely saying that by writing "IE 4 or
better", it is obvious what the author meant. There are _lots_ of things
that are wrong with that article, but I don't think this certain phrase is
one of them.
Well, my Opera 7.54 is newer than IE 4, and it doesn't support the JS
mentioned... I think the level of clarity remains the same when saying
"newer" or "better".

It's all down to personal taste anyway.
 
R

rf

Lenny Linux
And this goes for all newsgroup know it alls who like to swing it and have a
shortage of noodles in there heads who can't produce an answer but will jump
those who try.

Those "know it alls" did not produce an answer because there is no answer.
Not in the context of the web.

And your "answer" is not an answer at all, it is a problem. In fact if
someone used that onblur example of yours in certain places in Australia it
could be against certain anti discrimination laws. That is, illegal.
 
N

neredbojias

Without quill or qualm, Lenny Linux quothed:
And this goes for all newsgroup know it alls who like to swing it and have a
shortage of noodles in there heads who can't produce an answer but will jump
those who try.

Maybe that's why there's such a preponderance of "tag soup" - all the
noodles are in the soup! (-Get it?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top