[JavaScript]How to "auto" copy content of textbox to clipboard

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mattmao
    New Member
    • Aug 2007
    • 121

    [JavaScript]How to "auto" copy content of textbox to clipboard

    I am doing a ASP.NET porject, inside a asp control tag there are some textboxes for users to input data.

    Later they can take previously entered data out of those textboxes.

    To provide better UI efficiency, I would like to use JavaScripts to support "auto" copy to clipboard, but I don't know how to achieve that?

    Here is my code stub:
    Code:
    <script type="text/javascript">
        var input = document.getElementById("<%=txtUser.ClientID%>").text;
        function autocopy(input)
        {
            //it should pass input to windows clipboard, or any program
            // that can support the "ctrl+V" feature...
        }
    </script>
    I am quite a noob at javascript, so I really have no idea how to continue.

    Thanks in advance!
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    In IE, you can use something like:
    [code=javascript]window.clipboar dData.setData(" text",...);[/code]
    In Firefox, you will need to sign the script or allow it to run - see link. I'm not sure about other browsers.

    Comment

    Working...