Mouse Click Effect

Discussion in 'HTML' started by gcc, Nov 22, 2004.

  1. gcc

    gcc Guest

    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
     
    gcc, Nov 22, 2004
    #1
    1. Advertising

  2. On Mon, 22 Nov 2004 16:00:41 +0000, gcc wrote:

    > 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).


    --
    Jeffrey D. Silverman |
    Website | http://www.newtnotes.com

    Drop "PANTS" to reply by email
     
    Jeffrey Silverman, Nov 22, 2004
    #2
    1. Advertising

  3. gcc

    Steve Pugh Guest

    On Mon, 22 Nov 2004 11:21:08 -0500, Jeffrey Silverman
    <> wrote:

    > 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
     
    Steve Pugh, Nov 22, 2004
    #3
  4. On Mon, 22 Nov 2004 16:23:21 +0000, Steve Pugh wrote:

    > (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


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

    --
    Jeffrey D. Silverman |
    Website | http://www.newtnotes.com

    Drop "PANTS" to reply by email
     
    Jeffrey Silverman, Nov 22, 2004
    #4
  5. gcc

    Steve Pugh Guest

    On Mon, 22 Nov 2004 12:07:25 -0500, Jeffrey Silverman
    <> wrote:

    > On Mon, 22 Nov 2004 16:23:21 +0000, Steve Pugh wrote:
    >
    >> (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?
    >>

    > 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
     
    Steve Pugh, Nov 22, 2004
    #5
  6. gcc

    Mitja Guest

    On Mon, 22 Nov 2004 16:23:21 -0000, Steve Pugh <> wrote:

    > On Mon, 22 Nov 2004 11:21:08 -0500, Jeffrey Silverman
    > <> wrote:
    >
    >> 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.

    So was I... Then I searched and found the link below. Really surprised me.

    > So guess which browser lets you do just that?

    Mommy said no naughty language, so no elaborating about my opinion on JS
    clipboard access.
    http://www.htmlgoodies.com/beyond/clipboard.html

    --
    Mitja
     
    Mitja, Nov 22, 2004
    #6
  7. Mitja wrote:

    > http://www.htmlgoodies.com/beyond/clipboard.html


    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.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Nov 22, 2004
    #7
  8. gcc

    Lenny Linux Guest

    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>


    "gcc" <> wrote in message
    news:J2ood.31764$...
    > 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
    >
    >
     
    Lenny Linux, Nov 22, 2004
    #8
  9. gcc

    rf Guest

    Lenny Linux wrote:

    > 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?

    --
    Cheers
    Richard.
     
    rf, Nov 23, 2004
    #9
  10. gcc

    Lenny Linux Guest

    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" <rf@.invalid> wrote in message
    news:Bsxod.45383$...
    > Lenny Linux wrote:
    >
    > > 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?
    >
    > --
    > Cheers
    > Richard.
    >
    >
     
    Lenny Linux, Nov 23, 2004
    #10
  11. gcc

    rf Guest

    Lenny Linux wrote:

    [top posting fixed]

    rf wrote:

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


    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.

    --
    Cheers
    Richard.
     
    rf, Nov 23, 2004
    #11
  12. rf wrote:

    >> onFocus="this.blur()">


    > 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!

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Nov 23, 2004
    #12
  13. rf wrote:

    >> onFocus="this.blur()">


    > 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!

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Nov 23, 2004
    #13
  14. gcc

    Mitja Guest

    On Mon, 22 Nov 2004 22:21:59 +0000, David Dorward <>
    wrote:

    > Mitja wrote:
    >
    >> http://www.htmlgoodies.com/beyond/clipboard.html

    >
    > 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).

    </nitpicking> Maybe he should've written IE (4.0 or better)?

    > 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.

    --
    Mitja
     
    Mitja, Nov 23, 2004
    #14
  15. gcc

    Lenny Linux Guest

    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.





    "David Dorward" <> wrote in message
    news:cnuqvq$6je$2$...
    > rf wrote:
    >
    > >> onFocus="this.blur()">

    >
    > > 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!
    >
    > --
    > David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    > Home is where the ~/.bashrc is
     
    Lenny Linux, Nov 23, 2004
    #15
  16. Mitja wrote:

    > </nitpicking>


    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.

    > Maybe he should've written IE (4.0 or better)?


    "newer"

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Nov 23, 2004
    #16
  17. Lenny Linux wrote:

    > 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

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Nov 23, 2004
    #17
  18. gcc

    Mitja Guest

    On Tue, 23 Nov 2004 19:24:33 +0000, David Dorward <>
    wrote:

    > Mitja wrote:
    >
    >> </nitpicking>

    >
    > 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.

    >> Maybe he should've written IE (4.0 or better)?

    > "newer"

    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.

    --
    Mitja
     
    Mitja, Nov 23, 2004
    #18
  19. gcc

    rf Guest

    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.

    --
    Cheers
    Richard.
     
    rf, Nov 23, 2004
    #19
  20. gcc

    neredbojias Guest

    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?)

    --
    Neredbojias
    Contrary to popular belief, it is believable.
     
    neredbojias, Nov 24, 2004
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davisro
    Replies:
    2
    Views:
    1,345
    Jim Corey
    Apr 23, 2004
  2. =?Utf-8?B?am9qb2Jhcg==?=
    Replies:
    1
    Views:
    4,144
    wwwtar
    Oct 2, 2006
  3. Kid Kid
    Replies:
    6
    Views:
    507
  4. Lazlo Woodbine
    Replies:
    1
    Views:
    127
    Lazlo Woodbine
    May 14, 2004
  5. Daniish
    Replies:
    2
    Views:
    263
    Thomas 'PointedEars' Lahn
    Jun 13, 2008
Loading...

Share This Page