3/04/2013

Copy text into text box via Javascript when button clicked

it is very convenient for user to copy text from a  text box via javascript when click mouse. But now this function is just supported by IE, not by Firfox, Chrome.

Now I give the example for you to support the click and select, copy to clippad.

javascript code


function select_all(obj)
{  
    obj.focus();
    obj.select();  
    var r = obj.createTextRange();
    r.execCommand("Copy");
}


html code

<input onclick="select_all(this);" size="50" type="text" value="text value" />



No comments:

Post a Comment