如何在IE中的TextArea中查找选择文本 [英] How to Find Selection Text In TextArea In IE
本文介绍了如何在IE中的TextArea中查找选择文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我亲爱的朋友们
hi my dear friends
<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>
如何在IE浏览器中提醒选择文本!
仅限IE IE IE
谢谢,
how to Alert selection Text In IE browser!
Only IE IE IE
thanks
推荐答案
好吧,你要了!
这将在IE中起作用-在Chrome中将不起作用-尚未在其他地方进行测试:
Okay, you asked for it!
This will work in IE - it won''t work in Chrome - haven''t tested elsewhere:
function getalert()
{
var selTxtRng = document.selection.createRange();
var selTxt = selTxtRng.text;
alert(selTxt);
}
如果需要跨浏览器的实现,请在任何包含后期编辑器的代码项目"页面的源代码中查找功能"ToggleTagWrap". (用于快速解答"评论的编辑器"无效)
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)
这篇关于如何在IE中的TextArea中查找选择文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文