javascript 全集

发布时间:2009-1-14浏览:

核心提示:javascript 全集

第一章javascript简介 1.在地址栏输入javascript语句 Javascriptocument.write("显示文字") 2.将javascript嵌入HTML文档 <scriptlanguage=javascript> document.bgColor="blue" </script> 第二章使用变量和数组 1.声明变量 <scriptlanguage=javascripe> Varanswer1,answer2,answer3,answer4; answer1=9; answer2=2.5 answer3="MilkeyMay" answer4=true </script> 2.使用整数 <scriptlanguage=javascript> vardecimalNum,hexadecimalNum,octalNum decimalNum=24 hexadecimalNum=0x24 octalNum=024 document.write("显示十进制数:"+decimalNum+"<br>") document.write("显示十六进制数:"+hexadecimalNum+"<br>") document.write("显示八进制数:"+octalNum+"<br>") </script> 3.使用浮点数 <scriptlanguage=javascript> varnum1,num2,num3,num4 num1=1234567890000.0 num2=5.14e23 num3=0.0000123456 num4=6.0254e3-4 document.write("浮点数1:"+num1+"<br>") document.write("浮点数2:"+num2+"<br>") document.write("浮点数3:"+num3+"<br>") document.write("浮点数4:"+num4+"<br>") </script> 4.使用布尔值 <scriptlanguage=javascript> varanswer1,answer2 answer1=true answer2=false document.write("显示布尔1:"+answer1+"<br>") document.write("显示布尔2:"+answer2+"<br>") </script> 5.使用字符串 <scriptlanguage=javascript> varstr1,str2 str1="fdsgdgdsfdsfchina" str2="武汉市广播电视大学" document.write("显示字符串1:"+str1+"<br>") document.write("显示字符串2:"+str2+"<br>") </script> 6.确定变量类型 <script> varanswer1,answer2,answer3,answer4 answer1=9 answer2=2.5 answer3="milkymay" answer4=true document.write("变量1的类型是:"+typeofanswer1+"<br>") document.write("变量2的类型是:"+typeofanswer2+"<br>") document.write("变量3的类型是:"+typeofanswer3+"<br>") document.write("变量4的类型是:"+typeofanswer4+"<br>") </script> 7.将字符串转换成数字 <script> varstr1="31daysinjanuary" varint1=parseInt(str1) document.write("str1的数据类型是:"+typeofstr1+"<br>") document.write("int1的数据类型是:"+typeofint1+"<br>") </script> 8.将数字转换成字符串 <script> varint1=256 varstr1=""+int1 document.write("str1的数据类型是:"+typeofstr1+"<br>") document.write("int1的数据类型是:"+typeofint1+"<br>") </script>
前一篇:定做程序设计
后一篇:存储过程---用户注册
分享到: