Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi my dear friends

XML
<html>
<head>
</head>

<script type="text/javascript" language="javascript">
function getalert()
{
alert();
}
</script>

<body>

  <textarea id="TextArea1" ></textarea>
  <input type="button" onclick="getalert()" value="Clickme"/>

</body>
</html>



how to Alert selection Text In IE browser!
Only IE IE IE
thanks
Posted

1 solution

Okay, you asked for it!

This will work in IE - it won't work in Chrome - haven't tested elsewhere:
JavaScript
function getalert()
{
	var selTxtRng = document.selection.createRange();
	var selTxt = selTxtRng.text;
	alert(selTxt);
}


If you need a cross-browser implementation, look for the function "ToggleTagWrap" in the source code for any Code-Project page that includes a post editor. ('editor' used for Quick Answers comment wont work)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900