马克- to-win:马克 java社区:防盗版实名手机尾号:73203。马克-to-win:如果需要javascript工程师和html美工各干各的工作,需要分开写文件。例 1.2 Hello.js(如果你用notepad建立一个txt之后你再改为js,一定在存时,要存成utf-8或unicode格式): var a ; /*before you set value, a' type can not be defined.*/ document.writeln(typeof(a) + "
他们"); a = true; document.writeln(typeof(a) + "
"); /*下面的console.log只有安装了firebug的firebox不报错*/ console.log("This is the 1 message 马克-to-win write in %s", a); document.writeln(a);
2.简单语法: 例 2.1 var i = 0; do { i += 1; window.document.write("i=" + i + "
"); } while (i < 3)我们输出结果:i=1i=2i=3我们
例 2.2/span> "http://www.w3.org/TR/html4/loose.dtd"> var i = 5; while (i > 0) { window.document.write("i is" + i + "
"); i--; } 输出结果:i is5i is4i is3i is2i is1例 2.3(自动转化,比如3 result = 0; function qiuhe() { var num = window.document.getElementById("num").value; /*the following typeof(num) is a string. can automatically convert string to number.*/ alert("typeof(num) is "+typeof(num)); for (var i = 1; i <= num; i++) { result = result+i; } window.document.getElementById("result").value = result; } 1加到和是
由于篇幅关系, 阅读全文请点击左下角“阅读原文”
或者(以下链接必须打开一个新的浏览器,粘贴到地址栏才能工作):
http://www.mark-to-win.com/tutorial/js_1_htmIntroJs.html
百度中搜索“马克Java社区”到咱们官网上,可以找到所有的文章。