标签:资源 string 输出 hello 验证 ESS 距离 user tar
<script> ... </script>
<html> <head> <title>JavaScript Page</title> </head> ? <body> <script type="text/javascript"> document.write("<p>Hello world!</p>"); document.write("<p>输出 HTML 标签没压力" +"<i>hello world</i>?</p> "); </script> <p> 这是一些静态内容。 </p> </body> </html>
<html> <head> <title>Data Types and Variables</title> </head> ? <body> <script type="text/javascript"> var x, y; x= 1024; y=x; x = "foobar"; document.write("<p>x = " + y + "</p>"); document.write("<p>x = " + x + "</p>"); </script> </body> </html>
<!--将一张纸持续对折,在纸张的厚度达到从地面到太阳的距离之前,需要折叠多少次?--> <body> <script type="text/javascript"> var distanceToSun = 93.3e6*5280*12; var thickness = .002; var foldCount = 0; while (thickness < distanceToSun) { thickness *= 2; foldCount++; } document.write(" 共需要折 <b>" + foldCount +"</b> 次。 "); </script> </body>
<script> var txt = "Hello"; document.write(txt.length+"</br>"); // 属性 document.write(txt.replace(‘e‘,‘i‘)+"</br>")//封装函数 document.write(txt.search(‘l‘)); </script>
prompt(message, value)
<body> <script type="text/javascript"> var userName = prompt(" 请输入姓名: ", " 小明 "); var userAge = prompt(" 请输入年龄: ", "20"); var userAge = parseFloat(userAge); if (userAge < 18) { document.write("<h1> 未成年人适度上网! </h1>"); } else { document.write("<h1> 欢迎你, "+userName+" ! </h1>"); } </script> <p>The rest of the page...</p> </body>
Math.sqrt | Math.pow | Math.abs | Math.max | Math.min |
Math.floor | Math.cell | Math.round | Math.PI | Math.E |
Math.random(返回0到1的实数) |
<body> <div style="text-align:center"> <script type="text/javascript"> var roll1 = Math.floor(Math.random()*6) + 1; var roll2 = Math.floor(Math.random()*6) + 1; document.write("<img src=‘die" + roll1 + ".gif‘/>"); document.write(" "); document.write("<img src=‘die" + roll2 + ".gif‘/>") </script> </div> </body> <!--Math.floor(Math.random()*6) 0-5-->
<script> eval("x=10;y=20;document.write(x*y)"); document.write("<br>" + eval("2+2")); document.write("<br>" + eval(x+17)); </script>
标签:资源 string 输出 hello 验证 ESS 距离 user tar
原文地址:https://www.cnblogs.com/tianjiazhen/p/12235543.html