以下是常用js 语句和语句模版;写代码时可拷贝后修改;
1
<script src="myScript.js"></script>
<script>
</script>
<script type="text/javascript" src="a.js">
</script>
2
function myFunction()
{
}
<script>
function myFunction()
{
}
</script>
window.onload = function(){
var obj = document.getElementById("test");
};
timer = setInterval(function () {
}
3
var firstname;
var x="";
var x;
var style = null;
var arr = new Array(0,1,2,3,4);
var time=new Date().getHours();
var d=new Date().getDay();
var r=Math.random();
var x=document.getElementById("demo");
var obj = document.styleSheets[0];
var rect = element.getBoundingClientRect();
document.write();
document.write(Date());
document.getElementById("mydemo").innerHTML="你好世界";
document.getElementsByName(elementName);
document.getElementsByTagName(tagName);
document.documentElement.clientTop;
document.documentElement.clientLeft;
document.createElement("span");
parent.appendChild();
x.innerHTML="<a href='http://wwf.org'>Visit WWF</a>";
color = (Math.random() * 0xFFFFFF).toString(16).toString().split(".")[0];
vx = Math.random() * 6 - 3;
4
function myFunction()
{
document.getElementById("mydiv").innerHTML="你好世界";
}
function myFunction()
{
alert("你好,我是一个警告框!");
}
5
if ()
{
}
if ()
{
}
else
{
}
switch (d)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
}
for (var i = 0; i < count; i++) {
}
6
<button οnclick="myFunction()">点击这里</button>
7
alert("你好,我是一个警告框!");
8
document.cookie="userId=828";
document.cookie="userId=828; userName=hulk";
var strCookie=document.cookie;
document.cookie="userId=828; userName=hulk; expires="+date.toGMTString();
9
window.location.href="xxxx.jsp?backurl="+window.location.href;
window.history.back(-1);
window.navigate("xxxx.jsp");
self.location='xxxx.htm';
top.location='xxxx.jsp';