2008/11/21
状态栏定时器:
状态栏滚动文字:
检测浏览器和操作系统:
自动关闭的弹窗:
带声音的幻灯片切换:
Link对象:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>定时器的使用</title>
</head>
<script language="javascript" type="text/javascript">
var timer;
function start(){
date = new Date().toLocaleString();
window.status=date;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="button" name="Submit" value="显示时钟" onclick="timer=setInterval('start()',1000)"/>
</label>
<label>
<input type="submit" name="Submit2" value="停止显示" onclick="clearInterval(timer)"/>
</label>
</form>
</body>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>定时器的使用</title>
</head>
<script language="javascript" type="text/javascript">
var timer;
function start(){
date = new Date().toLocaleString();
window.status=date;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="button" name="Submit" value="显示时钟" onclick="timer=setInterval('start()',1000)"/>
</label>
<label>
<input type="submit" name="Submit2" value="停止显示" onclick="clearInterval(timer)"/>
</label>
</form>
</body>
状态栏滚动文字:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>状态栏滚动文字</title>
<script language="javascript" type="text/javascript">
<!--
// 定义要滚动的字符串
var scrtxt = "欢迎来到JavaScript的精彩世界...";
// 获取滚动显示的字符串的长度
var length = scrtxt.length;
// 定义状态栏中用于显示字符串的空间的宽度
var width = 100;
// 定义起始置为-102
var pos = -(width +2 );
function scroll() {
pos++;
var scroller = "";
//如果位置参数已经等于字符串长度则回到初始位置
if (pos == length) {
pos = -(width + 2);
}
//如果字符串还没有显示完整
if (pos < 0) {
//用循环在显示的部分字符前加若干空格
for (var i = 1; i <= Math.abs(pos); i++) {
scroller = scroller + " ";
}
scroller = scroller + scrtxt.substring(0, width - i + 1);
}else{
scroller = scroller + scrtxt.substring(pos, width + pos);
}
//将当前要显示的部分字符发送到状态栏
window.status = scroller;
//0.2秒执行一次,以使显示出来的字符串内容得到更新并向左移动
setTimeout("scroll()", 200);
}
//-->
</script>
</head>
<body onload='scroll()'>
<h2>状态栏滚动文字特效</h2>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>状态栏滚动文字</title>
<script language="javascript" type="text/javascript">
<!--
// 定义要滚动的字符串
var scrtxt = "欢迎来到JavaScript的精彩世界...";
// 获取滚动显示的字符串的长度
var length = scrtxt.length;
// 定义状态栏中用于显示字符串的空间的宽度
var width = 100;
// 定义起始置为-102
var pos = -(width +2 );
function scroll() {
pos++;
var scroller = "";
//如果位置参数已经等于字符串长度则回到初始位置
if (pos == length) {
pos = -(width + 2);
}
//如果字符串还没有显示完整
if (pos < 0) {
//用循环在显示的部分字符前加若干空格
for (var i = 1; i <= Math.abs(pos); i++) {
scroller = scroller + " ";
}
scroller = scroller + scrtxt.substring(0, width - i + 1);
}else{
scroller = scroller + scrtxt.substring(pos, width + pos);
}
//将当前要显示的部分字符发送到状态栏
window.status = scroller;
//0.2秒执行一次,以使显示出来的字符串内容得到更新并向左移动
setTimeout("scroll()", 200);
}
//-->
</script>
</head>
<body onload='scroll()'>
<h2>状态栏滚动文字特效</h2>
</body>
</html>
检测浏览器和操作系统:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>检测浏览器和操作系统</title>
</head>
<body>
<script language="javascript" type="text/javascript">
var isIE = (navigator.appName=="Microsoft Internet Explorer");
var isNetscape = (navigator.appName=="Netscape");
var isWin = (navigator.userAgent.indexOf("Win") != -1);
var isMac = (navigator.userAgent.indexOf("Mac") != -1);
var isUnix = (navigator.userAgent.indexOf("X11") != -1);
var isJava = navigator.javaEnabled()?"支持Java":"不支持Java";
document.write("您的浏览器为:" + (isIE?"Microsoft Internet Explorer":(isNetscape?"Netscape":"非IE和Netscape")) + "<br/>");
var system = "";
if(isWin){
system = "Windows";
}else if(isMac){
system = "Mac";
}else{
system = "Unix";
}
document.write("您的操作系统为:" + system + "<br/>");
document.write("您的浏览器" + isJava);
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>检测浏览器和操作系统</title>
</head>
<body>
<script language="javascript" type="text/javascript">
var isIE = (navigator.appName=="Microsoft Internet Explorer");
var isNetscape = (navigator.appName=="Netscape");
var isWin = (navigator.userAgent.indexOf("Win") != -1);
var isMac = (navigator.userAgent.indexOf("Mac") != -1);
var isUnix = (navigator.userAgent.indexOf("X11") != -1);
var isJava = navigator.javaEnabled()?"支持Java":"不支持Java";
document.write("您的浏览器为:" + (isIE?"Microsoft Internet Explorer":(isNetscape?"Netscape":"非IE和Netscape")) + "<br/>");
var system = "";
if(isWin){
system = "Windows";
}else if(isMac){
system = "Mac";
}else{
system = "Unix";
}
document.write("您的操作系统为:" + system + "<br/>");
document.write("您的浏览器" + isJava);
</script>
</body>
</html>
自动关闭的弹窗:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>自动关闭的弹出窗口</title>
<script language="javascript" type="text/javascript">
<!--
var popWin;
//弹出窗口函数
function popWin(){
popWin = window.open('ad.html','win','width=250,height=200');
setTimeout('closeWin()',8000);
}
//关闭弹出窗口函数
function closeWin(){
if(popWin && !popWin.closed){
popWin.close();
}
}
//-->
</script>
</head>
<body onload='popWin()'>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>自动关闭的弹出窗口</title>
<script language="javascript" type="text/javascript">
<!--
var popWin;
//弹出窗口函数
function popWin(){
popWin = window.open('ad.html','win','width=250,height=200');
setTimeout('closeWin()',8000);
}
//关闭弹出窗口函数
function closeWin(){
if(popWin && !popWin.closed){
popWin.close();
}
}
//-->
</script>
</head>
<body onload='popWin()'>
</body>
</html>
带声音的幻灯片切换:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>带声音的幻灯片切换</title>
<script language="javascript" type="text/javascript">
<!--
var image;
var current = 0;
var images= new Array(5);
//定义变量timerID用于保存定时器的ID
var timerID ;
var splayer = null;
function init(){
for(var i=0; i<images.length; i++){
images[i] = new Image(300,300);
images[i].src = "images/" + i + ".jpg";
}
image = document.images[0];
splayer = document.getElementById('sound');
}
function setSrc(i){
current = i;
//设置图像的src属性,以此来实现图像的切换
image.src = images[i].src;
splayer.Stop();
//播放声音
splayer.Play();
}
function next(){
if(current>=4){
return false;
}else{
//变量current的值自加1
current++;
setSrc(current);
}
}
function previous(){
if(current<=0){
return false;
}else{
//变量current的值自减1
current--;
setSrc(current);
}
}
function play(){
//当图像为最后一张时设置图像为第1张
if(current>=4){
current=-1;
}
setSrc(++current);
}
//-->
</script>
</head>
<body onload="init()">
<h2>带声音的幻灯片切换</h2>
<form id="form1" name="form1" method="post" action="">
<input type="button" name="Submit" value="第一张" onclick="setSrc(0)"/>
<input type="button" name="Submit2" value="上一张" onclick="previous()"/>
<input type="button" name="Submit3" value="下一张" onclick="next()"/>
<input type="button" name="Submit4" value="最后一张" onclick="setSrc(4)"/>
<input type="button" name="Submit5" value="幻灯播放"onclick="timerID=setInterval(play,1000)" />
<input type="button" name="Submit6" value="停止播放" onclick="clearInterval(timerID)"/>
</form>
<p>
<div align="center"><img src="images/0.jpg" /></div>
<!--嵌入声音文件-->
<embed id="sound" src="sound.wav" autostart='false' width="0" height="0"></embed>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>带声音的幻灯片切换</title>
<script language="javascript" type="text/javascript">
<!--
var image;
var current = 0;
var images= new Array(5);
//定义变量timerID用于保存定时器的ID
var timerID ;
var splayer = null;
function init(){
for(var i=0; i<images.length; i++){
images[i] = new Image(300,300);
images[i].src = "images/" + i + ".jpg";
}
image = document.images[0];
splayer = document.getElementById('sound');
}
function setSrc(i){
current = i;
//设置图像的src属性,以此来实现图像的切换
image.src = images[i].src;
splayer.Stop();
//播放声音
splayer.Play();
}
function next(){
if(current>=4){
return false;
}else{
//变量current的值自加1
current++;
setSrc(current);
}
}
function previous(){
if(current<=0){
return false;
}else{
//变量current的值自减1
current--;
setSrc(current);
}
}
function play(){
//当图像为最后一张时设置图像为第1张
if(current>=4){
current=-1;
}
setSrc(++current);
}
//-->
</script>
</head>
<body onload="init()">
<h2>带声音的幻灯片切换</h2>
<form id="form1" name="form1" method="post" action="">
<input type="button" name="Submit" value="第一张" onclick="setSrc(0)"/>
<input type="button" name="Submit2" value="上一张" onclick="previous()"/>
<input type="button" name="Submit3" value="下一张" onclick="next()"/>
<input type="button" name="Submit4" value="最后一张" onclick="setSrc(4)"/>
<input type="button" name="Submit5" value="幻灯播放"onclick="timerID=setInterval(play,1000)" />
<input type="button" name="Submit6" value="停止播放" onclick="clearInterval(timerID)"/>
</form>
<p>
<div align="center"><img src="images/0.jpg" /></div>
<!--嵌入声音文件-->
<embed id="sound" src="sound.wav" autostart='false' width="0" height="0"></embed>
</body>
</html>
Link对象:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Link对象</title>
</head>
<script language="javascript" type="text/javascript">
function getLink() {
win = window.open('','','width=250,height=200');
//使用length属性获取链接的个数
win.document.write("共有" + document.links.length + "个网址:<br/>");
for (var i = 0; i < document.links.length; i++) {
win.document.write("<li>"+document.links[i] + "</li>");
}
//一定要记得关闭文档
win.document.close();
}
</script>
<body>
<p>
常用的网址:
</p>
<A HREF="http://www.baidu.com/">百度</A>
<A HREF="http://www.google.com/">谷歌</A>
<A HREF="http://www.sina.com/">新浪</A>
<A HREF="JavaEyehttp://www.javaeye.com/">JavaEye</A>
<A HREF="http://www.163.com/">网易</A>
<A HREF="CSDNhttp://www.csdn.net/">CSDN</A>
<p>
<form>
<input type="button" value="查看网址" onClick="getLink()"/>
</form>
</p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Link对象</title>
</head>
<script language="javascript" type="text/javascript">
function getLink() {
win = window.open('','','width=250,height=200');
//使用length属性获取链接的个数
win.document.write("共有" + document.links.length + "个网址:<br/>");
for (var i = 0; i < document.links.length; i++) {
win.document.write("<li>"+document.links[i] + "</li>");
}
//一定要记得关闭文档
win.document.close();
}
</script>
<body>
<p>
常用的网址:
</p>
<A HREF="http://www.baidu.com/">百度</A>
<A HREF="http://www.google.com/">谷歌</A>
<A HREF="http://www.sina.com/">新浪</A>
<A HREF="JavaEyehttp://www.javaeye.com/">JavaEye</A>
<A HREF="http://www.163.com/">网易</A>
<A HREF="CSDNhttp://www.csdn.net/">CSDN</A>
<p>
<form>
<input type="button" value="查看网址" onClick="getLink()"/>
</form>
</p>
</body>
</html>


2008/11/21 20:10,
PHP相关认证介绍
RCNA


