Select Div Tag Area - Code

Selecting DIV Tag: You can use this free javascript code to select the contents of Div Tag area just by clicking a button.

Features

  • Just click the button below and select all the contents within Div tag.
  • Press control + C and copy the contents and paste it anywhere.

Downloads







<!--Script by hscripts.com-->
<!-- Free javascripts @ https://www.hscripts.com -->
<script type="text/javascript">
function fnSelect(objId)
{
fnDeSelect();
if (document.selection)
{
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(objId));
range.select();
}
else if (window.getSelection)
{
var range = document.createRange();
range.selectNode(document.getElementById(objId));
window.getSelection().addRange(range);
}
}
function fnDeSelect()
{
if (document.selection)
document.selection.empty();
else if (window.getSelection)
window.getSelection().removeAllRanges();
}
</script>
<!-- Script by hscripts.com -->


  • Release Date - 20.6.2007
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to support@hscripts.com

Usage

  • Create a div tag area having its id as "testarea", to type the text say 'abcdf' within the div tag.
  • Ex:- <div class="copybox" id="testarea">abcdf
  • Create a button with any name and call the function fnSelect(testarea) by using onclick event.
  • Ex- <input type="button" value="Copy Code" onClick="fnSelect('testarea')">
  • Now just copy the above free javascript selecting code in to your web pages head tag and test it for selection of contents within div tags.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question