javascript length字符串长度检测函数
string.length 这样可以测试到字符串的长度哦,这对js入门的朋友会有所帮助
获取一个字符串的长度实例
<html>
<head>
<script type="text/网页特效" language="javascript">
<!-- //
onload = function(){
var myString = "AAA";
document.write(myString + " has a length of " + myString.length + " characters.");
}
// -->
</script>
</head>
<body></body>
</html>
更详细的实例。
<html>
<script language="JavaScript">
<!--
var myString1 = new String("Hello, World");var myString2 = new String("Here is a longer string");
var myString3 = new String("Here is an even longer string");
document.write(myString1 + ": is " + myString1.length);
document.write(" characters long.<br>");
document.write(myString2 + ": is " + myString2.length);
document.write(" characters long.<br>");
document.write(myString3 + ": is " + myString3.length);
document.write(" characters long.<br>");
document.close();
--></script>
</html>
补充:网页制作,js教程