|
楼主 |
发表于 2013-8-30 09:07:37
|
显示全部楼层
想实现这个,标准js如下:
可是在.w文件里这些方法都不支持了?????如何使用标准js方法,或者用x5的js可以实现吗?- <body>
- <form method="get">
- <div><textarea id="content" cols="50" rows="5">先在本文框中点鼠标以确定光标位置。</textarea></div>
- <div><input type="button" value="插入文字"A"" onclick="javascript:Insert('A');" /></div>
- <div><input type="button" value="插入文字"B"" onclick="javascript:Insert('B');" /></div>
- </form>
- <script type="text/javascript" language="javascript">
- function Insert(str) {
- var obj = document.getElementById('content');
- if(document.selection) {
- obj.focus();
- var sel=document.selection.createRange();
- document.selection.empty();
- sel.text = str;
- } else {
- var prefix, main, suffix;
- prefix = obj.value.substring(0, obj.selectionStart);
- main = obj.value.substring(obj.selectionStart, obj.selectionEnd);
- suffix = obj.value.substring(obj.selectionEnd);
- obj.value = prefix + str + suffix;
- }
- obj.focus();
- }
- </script>
- </body>
复制代码 |
-
实现功能
|