SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    copy to clipboard

    hey..Is there any way we could copy the text by clocking on a button? This is working fine on IE but not on any other browsers.
    http://javascript.internet.com/forms...oard-copy.html
    But the above one is not working all the time.

    Thanks,

    Koushik

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,813
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    It can't be done with JavaScript since JavaScript doesn't have access to the clipboard (and many platforms running browsers that use JavaScript don't even have a clipboard).

    There are only two ways to do it.

    1. Use JScript (which only runs on IE which is ther reason why the code you currently have works in IE only as that is a JScript command that doesn't have a JavaScript equivalent).
    2. Use Flash (and hope that your visitors have Flash enabled).

    There is no way to do it for those of your visitors with scripting completely disabled or whoi have JavaScript enabled and Flash disabled.
    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="^$">

  3. #3
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,621
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Couldn't they store the text in a variable on click and then hold that information until they wish to paste it? Find keystrokes for CTRL+V and then have a custom rightclick menu for pasting? Probably a little work but it should be possible.
    Always looking for web design/development work.
    Willing to do it cheap to build portfolio!

  4. #4
    Non-Member
    Join Date
    Oct 2007
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only possible way to do this in ff3 is with flash. If you want an example, take a look at snipt.net.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,813
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by RyanReese View Post
    Couldn't they store the text in a variable on click and then hold that information until they wish to paste it? Find keystrokes for CTRL+V and then have a custom rightclick menu for pasting? Probably a little work but it should be possible.
    It might for those browsers where custom context menus haven't been disabled. You also have the problem that paste isn't necessarily Ctrl-V (that's the Windsows only shortcut).
    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="^$">


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
  •