<html>
<head runat="server">
<title>Select Text</title>
</head>
<body>
<form id="form1" runat="server">
<div id="SelectDiv">
<table style="width: 100%;">
<tr>
<td>Text to select.</td>
</tr>
</table>
</div>
<br />
<asp:Button ID="SelectDataButton" runat="server" Text="Select Data" OnClientClick="selectText(); return false;" UseSubmitBehavior="False" />
</form>
<script type='text/javascript'>
function selectText() {
if (document.selection) {
var div = document.body.createTextRange();
div.moveToElementText(document.getElementById('SelectDiv'));
div.select();
}
else {
var div = document.createRange();
div.setStartBefore(document.getElementById('SelectDiv'));
div.setEndAfter(document.getElementById('SelectDiv'));
window.getSelection().addRange(div);
}
}
</script>
</body>
</html>
Select an area of page on button click
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment