上一篇:试试看这个,可能和你的要求不一样,但是可是实现一样的功能 >>
string.substring();
Returns the substring at the specified location within a String object.
strVariable.substring(start, end)
"String Literal".substring(start, end)
Arguments
start
The zero-based index integer indicating the beginning of the substring.
end
The zero-based index integer indicating the end of the substring.
Remarks
The substring method returns a string containing the substring from start up to, but not including, end.
The substring method uses the lower value of start and end as the beginning point of the substring. For example, strvar.substring(0, 3) and strvar.substring(3, 0) return the same substring.
If either start or end is NaN or negative, it is replaced with zero.
The length of the substring is equal to the absolute value of the difference between start and end. For example, the length of the substring returned in strvar.substring(0, 3) and strvar.substring(3, 0) is three.
Example
The following example illustrates the use of the substring method.
function SubstringDemo(){
var ss; //Declare variables.
var s = "The rain in Spain falls mainly in the plain..";
ss = s.substring(12, 17); //Get substring.
return(ss); //Return substring.
}
下一篇:如何使用MsgBox? >>
相关文章:
- · 利用JS在页面上动态生成直线
- · 一般的复选框一定要按在复选框上才能被选中,这个复选框点击相应的文字就可以被选中
- · 利用JS动态改变图片大小
- · event对象详解
- · 关于AutoComplete(文本框的自动填充)
- · 在页面上定义元件热键的方法
- · window.external的使用
- · 利用HTC技术限制多行输入框的内容的长度(转载)
- · “画中画”效果---谈Iframe标记的使用
- · COOKIE欺骗 (转贴)
- · 当页面正在被下载时在页面上显示loading.....的例子
- · 使用javascript改进你的框架 (摘)
- · 这是我在网上摘入的,贴上来与大家一起学习学习。 在javascript中应用Object(1)
- · 在javascript中应用Object (2)
- · 在javascript中应用Object (3)
- · 对连串英文自动换行的解决方法 IE5.5
- · 在html文件引入其它html文件的几种方法
- · 两种屏蔽鼠标右键的方法
- · 如何让页面只自动刷新一次
- · 再继(太长了)
- · 继(太长了)
- · 加密页面代码生成器
- · ASCII 字形生成器
- · IE 5.5 的内置编辑器(在MSDN ONLINE翻出来的资料)
- · 滚动条颜色生成器IE5.5+
- · 设置open方法中的参数
- · 打开页面就是全屏的方法
- · javascript 实现下拉列表连动,提示:Array not defined
- · 利用javascript实现时间段的查询
- · 表单填写时用 回车 代替 TAB 的实现方式
- · javascript里类似select case 该如何用?
- · javascript里类似select case 该如何用?
- · 在javascript 里面有没有检查日期格式的函数?
- · js中with的和case的用法
- · asp的cookie本身不设置的话默认的是application的path=/,所以不设关系不大,expires要设。给你netscape...
- · html的标准里这样写的。
- · Dreamweaver 4 & UltraDev 4两个BUG(字体设置不能保存和行号显示错位)的解决方法
- · 一个DHTML的例子——3D文字
