var str = "asd我ADGSE我~爱.北京";
window.document.write(str.length + "<br/>");
window.document.write(str.charAt(1) + "<br/>");
window.document.write(str.indexOf("d我", 0) + "<br/>");
window.document.write(str.lastIndexOf("家", 2) + "<br/>");
window.document.write(str.split(/~|\./) + "<br/>");
window.document.write(str.substr(0, 2) + "<br/>");
window.document.write(str.substring(0, 3) + "<br/>");
window.document.write(str.toLowerCase() + "<br/>");
window.document.write(str.toUpperCase() + "<br/>");
方法 | 描述 | FF | IE |
---|---|---|---|
anchor() | 创建 HTML 锚。 | 1 | 3 |
big() | 用大号字体显示字符串。 | 1 | 3 |
blink() | 显示闪动字符串。 | 1 | |
bold() | 使用粗体显示字符串。 | 1 | 3 |
charAt() | 返回在指定位置的字符。 | 1 | 3 |
charCodeAt() | 返回在指定的位置的字符的 Unicode 编码。 | 1 | 4 |
concat() | 连接字符串。 | 1 | 4 |
fixed() | 以打字机文本显示字符串。 | 1 | 3 |
fontcolor() | 使用指定的颜色来显示字符串。 | 1 | 3 |
fontsize() | 使用指定的尺寸来显示字符串。 | 1 | 3 |
fromCharCode() | 从字符编码创建一个字符串。 | 1 | 4 |
indexOf() | 检索字符串。 | 1 | 3 |
italics() | 使用斜体显示字符串。 | 1 | 3 |
lastIndexOf() | 从后向前搜索字符串。 | 1 | 3 |
link() | 将字符串显示为链接。 | 1 | 3 |
localeCompare() | 用本地特定的顺序来比较两个字符串。 | 1 | 4 |
match() | 找到一个或多个正则表达式的匹配。 | 1 | 4 |
replace() | 替换与正则表达式匹配的子串。 | 1 | 4 |
search() | 检索与正则表达式相匹配的值。 | 1 | 4 |
slice() | 提取字符串的片断,并在新的字符串中返回被提取的部分。 | 1 | 4 |
small() | 使用小字号来显示字符串。 | 1 | 3 |
split() | 把字符串分割为字符串数组。 | 1 | 4 |
strike() | 使用删除线来显示字符串。 | 1 | 3 |
sub() | 把字符串显示为下标。 | 1 | 3 |
substr() | 从起始索引号提取字符串中指定数目的字符。 | 1 | 4 |
substring() | 提取字符串中两个指定的索引号之间的字符。 | 1 | 3 |
sup() | 把字符串显示为上标。 | 1 | 3 |
toLocaleLowerCase() | 把字符串转换为小写。 | - | - |
toLocaleUpperCase() | 把字符串转换为大写。 | - | - |
toLowerCase() | 把字符串转换为小写。 | 1 | 3 |
toUpperCase() | 把字符串转换为大写。 | 1 | 3 |
toSource() | 代表对象的源代码。 | 1 | - |
toString() | 返回字符串。 | - | - |
valueOf() | 返回某个字符串对象的原始值。 | 1 | 4 |