控制背景颜色
<SCRIPT LANGUAGE="JavaScript">
function changeBg(sel){
if(sel.value!=""){
document.body.bgColor=sel.value;
}
}
</SCRIPT>
直线
<hr width="50%" align="left" size="1" noshade="noshade" />
--------------------------------------------------------------------
加粗斜体下划线
<b><i><u>独钓寒江雪</u></i></b>
<a href="mailto:[email protected]">发送简历</a>
<a href="down/javaexam.rar">本地下载</a>
<a href="http://www.newhua.com/ro/client0903.exe">电信下载</a>
锚的使用
<p><a href="#chibi">赤壁</a> </p>
<p><a name="chibi">赤壁</a><br>
折戟沉沙铁未销,自将磨洗认前朝。<br>
东风不与周郎便,铜雀春深锁二乔。</p>
---------------------------------------------------------------------
div的使用
<div align="center">
<div style="font-size:24px">渔翁</div>
<div style="background:#6F0">渔翁夜傍西岩宿,晓汲清湘燃楚竹。</div>
<div>烟销日出不见人,欸乃一声山水绿。</div>
<div>回看天际下中流,岩上无心云相逐。</div>
</div>
---------------------------------------------------------------------
div 立体层
<div id="Layer1" style="position:absolute; left:165px; top:102px;
width:239px; height:166px; z-index:1">
<img src="pic/92.jpg" width="236" height="164"></div>
<div id="Layer2" style="position:absolute; left:103px; top:23px;
width:210px; height:192px; z-index:2">
--------------------------------------------------------------------
可口可乐
一种休闲饮料,来源于美国一个药剂配方
<dl>
<dt>可口可乐</dt>
<dd>一种休闲饮料,来源于美国一个药剂配方</dd>
</dl>
----------------------------------------------------------------------
<embed src="sound/demo.mp3" autostart="true" loop="true" width="0" height="0"></embed>
<embed src="video/welcome.swf" width="400" height="300" ></embed>
图片超链接
<a href="poem_001.htm"><img src="pic/logo.gif"></a>
<img src="pic/logo.gif" width="100px" height="500px">
表的使用
<table width="364" height="191" border="1" align="center" bordercolor="#FF0000" cellspacing="1" cellpadding="10">
<tr>
<td colspan="4"> </td>
</tr>
<OL type="a"start="2">
<li>宣州谢[月兆]楼饯别校书叔云</li>
</OL>
居中显示
<center>
窗前明月光<br/>
</center>
< >
<>
行内样式
<div style="color:red;width:300px;border:1px #0000ff solid;text-align:center">
久为簪组累,幸此南夷谪。<br/>
</div>
border:#600 dotted; 边框为星点
下拉列表
<select>
<option value="zhangjl">张九龄</option>
<option value="lib">李白</option>
</select>
<select name="sport" size="1" multiple> //有上下拉动按钮
-------JS部分
<body onunload="alert('bye!');">关闭此页面的的时候
document.write('欢迎来到JAVASCRIPT!');
confirm("要喝茶吗?") //弹出一个选择框 返回值为 boolean
document.getElementById("CSSLink").href="style2.css";//换肤
var k = window.showModalDialog("child.html",window,
"dialogWidth:335px;status:no;dialogHeight:300px");
<span id="txt" style="display: none">不显示
document.getElementById("txt").style.display = "block";
跳转
onClick="window.location.href='setTimeout2.html';"
document.write("你的浏览器名称是"+navigator.appName);
document.write("<hr/>你的浏览器版本是"+navigator.appVersion);
function doInput(txt) //文本框传值
//下拉列表传值
function changeurl(selectObj){
location.href=selectObj.value;
}
//页面刷新的用法
onClick="window.location.reload();"
document.write(window.screen.availWidth+"<br/>");
document.write(window.screen.availHeight+"<br/>");
document.write(window.screen.bufferDepth+"<br/>");
document.write(window.screen.colorDepth+"<br/>");
document.write(window.screen.deviceXDPI+"<br/>");
//数组的应用
var poem = ['adf','ddd',33,78];
//循环数组的另一种方法
for(var x in list){
document.write("<p>"+list[x]+"</p>");
}
var now= new Date();
var hour = now.getHours();
now.getYear()
now.getDate()
now.getMinutes( )
//变换背景图片
document.body.background="img/"+picnum+".jpg";
//设置间隔 没3秒调用函数
<body onLoad="setInterval('changeBackPic()',3000)">
var time=setTimeout("startRun()",100);
clearTimeout(time);
//定义一个类
function User(){
//this.tel=13812341234;
this.sayHi=function(msg){
alert("我是"+this.name+",大家好。"+msg);
}
}
User.prototype.name="小白";
var str="隐香遍天涯,暗魂染芳华。雨过风停处,骑马叹落花。";
var arr=str.split(/,|。/);
var s1=s.substr(3,5); 输出5个
var s2=s.substring(3,5);输出2个