<script>
var str1="31 days in january"
var int1=parseInt(str1)
document.write("str1的数据类型是 :"+typeof str1+"<br>")
document.write("int1的数据类型是 :"+typeof int1+"<br>")
</script>
8.将数字转换成字符串
<script>
var int1=256
var str1=""+int1
document.write("str1的数据类型是 :"+typeof str1+"<br>")
document.write("int1的数据类型是 :"+typeof int1+"<br>")
</script>
<script>
for(prop in window)
{document.write("window."+prop+"="+window[prop]+"<br>");}
for(prop2 in location)
{document.write("location."+prop2+"="+location[prop]+"<br>");}
</script>
<script>
str1="this is the bigginning of the page.<br>"
str2="….<br>"
str3="this is the end of the page .<br>"
str4="link to the start<br>"
str5="link to the end<br>"
document.write(str1.anchor("start"))
for(i=0;i<10;i++)
document.write(str2);
document.write(str3.anchor("end"))
document.write(str4.link("#start"))
document.write(str5.link("#end"))
</script>
6.确定字符串长度
<script>
str1="this is the bigginning of the page."
document.write(str1+"<br>")
document.write( "字符串的长度是:"+str1.length)
document.write("字符串全部大写是;"+str1.toUpperCase())
document.write("字符串全部小写是;"+str1.toLowerCase())
</script>
7.在字符串内搜索
<script>
str1="this is the end of the line.<br>"
document.write(str1)
document.write("字符end在字符串的位置是"+str1.search("end"))
document.write("字符dog在字符串的位置是"+str1.search("dog"))
</script>
8.定位字符串中的字符
<script>
str1="spring is a time for flowers and trees and baby bunnles<br>"
document.write(str1)
document.write("the index for the second word ‘and' is"+str1.indexOf("and",30))
documednt.write("the last index of the word ‘and' is "+str1.lastIndexOf("and"))
</script>
9.替换字符串中的文本
<script>
str1="spring is a time for flowers and trees and baby bunnles<br>"
document.write(str1)
document .write(str1.replace("and",","))
</script>
10.字符串分离
<script>
str1="spring is a time for flowers and trees and baby bunnles<br>"
document.write(str1)
str1array=str1.split(" ")
document.write(str1array[0]+"<br>")
document.write(str1array[1]+"<br>")
document.write(str1array[2]+"<br>")
document.write(str1array[3]+"<br>")
</script>
<form name=form1>
<input type=text name=text1 size=45><br>
<input type=button name=button1 value=panic button onclick="document.form1.text1.value='sittle down,count to 10 and take a deep breath'">
</form>
<form name=form1>
<textarea name=ta1>how many grains of sand are there in the sahara desert?</textarea>
</form>
<script>
document.write("表单ta1的类型:"+document.form1.ta1.type+"<br>")
document.write("表单ta1的名称:"+document.form1.ta1.name+"<br>")
document.write("表单ta1的值:"+document.form1.ta1.value+"<br>")
document.write("表单ta1的横向宽度:"+document.form1.ta1.cols+"<br>")
document.write("表单ta1的纵向宽度:"+document.form1.rows.value+"<br>")
</script>
<form name=form1>
<textarea name=ta1 rows=4 onfocus="document.form1.ta1.select()"> how many grains of sand are there in the sahara desert?</textarea>
</form>
<form name=form1>
<input type=text name=text1 size=45><br>
<input type=button name=button1 value=panic button onclick="document.form1.text1.value='sittle down,count to 10 and take a deep breath'">
</form>
<form name=form1>
<textarea name=ta1>how many grains of sand are there in the sahara desert?</textarea>
</form>
<script>
document.write("表单ta1的类型:"+document.form1.ta1.type+"<br>")
document.write("表单ta1的名称:"+document.form1.ta1.name+"<br>")
document.write("表单ta1的值:"+document.form1.ta1.value+"<br>")
document.write("表单ta1的横向宽度:"+document.form1.ta1.cols+"<br>")
document.write("表单ta1的纵向宽度:"+document.form1.rows.value+"<br>")
</script>
<form name=form1>
<textarea name=ta1 rows=4 onfocus="document.form1.ta1.select()"> how many grains of sand are there in the sahara desert?</textarea>
</form>