为什么此代码在IE中不起作用! [英] why This Code Is Not Act in IE!!!!!!!!?

查看:80
本文介绍了为什么此代码在IE中不起作用!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<HTML>
<HEAD><TITLE>Selection</TITLE>
<SCRIPT type="text/javascript">
function disp()
{
  var text = document.getElementById("text");
  var t = text.value.substr(text.selectionStart,text.selectionEnd-text.selectionStart);
  alert(t+"\nSelectionStart:"+text.selectionStart);

}
</SCRIPT>
</HEAD>
<BODY>

<TEXTAREA id="text">Hello, How are You?</TEXTAREA><BR>
<INPUT type="button"  value="Select text and click here"  onclick="disp();"/>
</BODY>
</HTML>

推荐答案


text.value.substr(text.selectionStart,text.selectionEnd-text.selectionStart);


检查第二个参数substr.它应该是整数.
试试这个:


Check your second parameter of substr. It should be integer.
Try this:

text.value.substr(text.selectionStart,10);





--Amit





--Amit


亲爱的朋友,

Dear Friend,

function disp()
{
    var text = document.getElementById("text").value;
    //  var t = text.substr(text.selectionStart,text.selectionEnd-text.selectionStart)
    var t = text.substr(text.selectionStart,10);
    alert(t+"\nSelectionStart:"+text.selectionStart);
}



< INPUT type ="button" id ="text" name ="text" value =选择文本并单击此处" onclick ="disp()"/>

希望这能满足您的要求.



<INPUT type="button" id="text" name="text" value="Select text and click here" onclick="disp()"/>

Hope this will fulfill your requirement.


这篇关于为什么此代码在IE中不起作用!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆