php and clipboard

Discussion in 'PHP' started by trichnosis, Mar 1, 2008.

  1. #1
    Hi;

    Is it possible to catch the clipboard event with php?

    like somebody has copied some text to clipboard

    Regards
     
    trichnosis, Mar 1, 2008 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #2
    PHP is a server-side language, so the answer is NO. Try to do it with javascript
     
    wmtips, Mar 1, 2008 IP
  3. marcel

    marcel Well-Known Member

    Messages:
    1,503
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    150
    #3
    Yes it is possible... i hope you have good reasons.

    PHP + Javascript + MySQL
     
    marcel, Mar 1, 2008 IP
  4. Tyler

    Tyler Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    As wmtips stated, PHP is a server-side language, so it cannot detect anything that is done on a client level. Javascript would be able to provide you with a solution.

    Depending on the use that the OP is after, PHP & MySQL may quite well be an overkill.
     
    Tyler, Mar 1, 2008 IP
  5. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #5
    Do you know any PHP or MySQL functions dealing with clipboard? :D
     
    wmtips, Mar 1, 2008 IP
  6. trichnosis

    trichnosis Prominent Member

    Messages:
    13,785
    Likes Received:
    333
    Best Answers:
    0
    Trophy Points:
    300
    #6
    as i see there is no function like this:(
     
    trichnosis, Mar 1, 2008 IP
  7. Tyler

    Tyler Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    PHP and MySQL alone can do absolutely nothing of the sort, as it's a server-side language. Javascript would handle the actual clipboard event, and then if you wanted to get something a bit more advance, you can use PHP/MySQL to parse it and store it in the database or do some other functions with it. But PHP and MySQL cannot do it at all, it has absolutely no barring on anything client-side.
     
    Tyler, Mar 2, 2008 IP
  8. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #8
    For IE, you can throw oncopy="" to your HTML elements (like onclick and onfocus and such) and do something. You can even then use that to alter what is copied to the clipboard (pass it a javascript function that has a return value. whatever is returned is copied to the clipboard instead I believe). Not sure if this works in Firefox or not, never tried.

    Example for how to catch it basically for the entire page:
    <body oncopy="return CopyText();">
    HTML:
    where CopyText can then alter the body's HTML or whatever.
     
    zerxer, Mar 2, 2008 IP
  9. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #9
    As far as I know, Firefox doesn't support this at all. So I wouldn't even bother...
     
    nico_swd, Mar 3, 2008 IP