javascript clipboard

In sometimes, in html , if you want to select the text for a textbox or a textarea , you can use the following script

<script type=”text/javascript”>

function select_all(obj)

{ var text_val=eval(obj);

text_val.focus();

text_val.select();

if (!document.all) return; // IE only

r= text_val.createTextRange();

r.execCommand(\\’copy\\’);

} </script>
The html part is:

<input value=”http://www.sajithmr.com” onclick=”select_all(this)” name=”url” type=”text” />The above script will select all the text for input field and copy to clipboard (for IE only)


Add to Del.cio.us RSS Feed Add to Technorati Favorites Stumble It!

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!