SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    how to get click to copy to clipboard and open a site?

    how to do click to copy to the clipboard and open site. examples of this kind of script can be viewed on this page www.retailmenot.com/ on the yellow boxes with the discount text.

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Copying items to the clipboard is highly not recommended as there are major security risks in doing so that hackers use to there advantage. In newer browsers this is not an issue as your required to allow and disallow access for a website to see your clipboard but in older browsers this by default is always set to allowed.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,807
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    JavaScript doesn't allow you to do things like that. You can do it in JScript which is Internet Explorer's equivalent language but only if the person visiting has certain security settings turned off on their computer.

    The best you can do that works across all browsers is to select all the content so that your visitor only has to press ctrl-C (or equivalent) to copy it to their clipboard.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SgtLegend View Post
    Copying items to the clipboard is highly not recommended as there are major security risks in doing so that hackers use to there advantage. In newer browsers this is not an issue as your required to allow and disallow access for a website to see your clipboard but in older browsers this by default is always set to allowed.
    there are major security risks? what's the security risks of it? could you give me more detail. thank you.

  5. #5
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    JavaScript doesn't allow you to do things like that. You can do it in JScript which is Internet Explorer's equivalent language but only if the person visiting has certain security settings turned off on their computer.

    The best you can do that works across all browsers is to select all the content so that your visitor only has to press ctrl-C (or equivalent) to copy it to their clipboard.
    if javascript can't get that? how this site (www.retailmenot.com) to get that effect?

    works across all browsers is to select all the content so that your visitor only has to press ctrl-C (or equivalent) to copy it to their clipboard. i don't know how to do this? could you give me more details? thank you

  6. #6
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    That site is using flash to copy content to the clipboard which from memory is 100% safe and will work across all browsers.

    Like i said using javascript and allowing it to have access to the clipboard allows a hacker to gain access to their entire clipboard history including passwords, usernames, emails etc.

  7. #7
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks, you make me know a lot. could you tell me how the site get this effect. (when i put my mouse over the discount text, it shows an image "click to copy& open site")

  8. #8
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Here's a flash work around i found http://bravo9.com/journal/copying-te...-d23e8bc5ad8a/

  9. #9
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thank you. i have get the effect. but still don't get this effect. (when i put my mouse over the discount text, it shows an image "click to copy& open site". which on the right of the discount text)

  10. #10
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SgtLegend View Post
    It's not working in chrome.

  11. #11
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by globestar View Post
    It's not working in chrome.
    Thats out of my control, i can only share what i find. You would need to get in contact with the original developer and try to find a more updated version.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •