js基础应用一,窗口震动
html+js代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script>
function zhengdong(){
moveBy(5,0);
moveBy(-5,0);
moveBy(-5,5);
moveBy(5,-5);
window.setInterval("zhengdong()",100);//实现一直震动
}
</script>
<body>
<form>
<input type="button" value="震动" οnclick="zhengdong()"/>
</form>
</body>
</html>
js基础应用二,打字机<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script>
var str="海上盛明月,天涯明月刀!";
var i=-1;//字符串的下标。
function printf(){
i++;
var s1=document.getElementById("print");//获取到html页面输入框的id
//
var str1=str.substring(0,i).fontcolor("blue").fontsize("18px");
s1.innerHTML=str1;//将取到的新的字符写入span标签内
if(i==12){//如果读到的i下标=12(最大长度)让它重新从开始打字
i=-1;
}
}
window.setInterval("printf()",300);
</script>
<body>
<span id="print"></span>
</body>
</html>