1、显示当前时间:

<!doctype>
<html>
<head>
<meta charset='utf-8'>
<script type='text/javascript'>
function showtime(){
var now_time = new date(); //创建时间对象的实例
var hours = now_time.gethours(); //获得当前小时数
var minutes = now_time.getminutes(); //获得当前分钟数
var seconds = now_time.getseconds(); //获得当前秒数
var timer = "" + ((hours > 12) ? hours - 12 : hours);
timer += ((minutes < 10) ? ":0" : ":") + minutes;
timer += ((seconds < 10) ? ":0" : ":") + seconds;
timer += " " + ((hours > 12) ? "pm" : "am");
document.getElementById("aa").text = timer;
settimeout('showtime()', 1000);
}
</script>
</head>
<body onload="showtime()">
<div id="aa"></div>
</body>
</html>

2、当鼠标经过图像时图像的震动效果:

<!doctype>
<html>
<head>
<meta charset='utf-8'>
<script type='text/javascript'>
var rector = 3, stopit = 0, a = 1;
function init(which){
stopit = 0;
zhend = which;
zhend.style.left = 0;
zhend.style.top = 0;
}
function rattleimage(which){
if((!document.all && !document.getElementById) || stopit = 1)
return;
if(a == 1){
zhend.style.top = parseInt(zhend.style.top) + rector;
} else if(a == 2){
zhend.style.left = parseInt(zhend.style.left) + rector;
} else if(a == 3){
zhend.style.top = parseInt(zhend.style.top) - rector;
} else if(a == 4){
zhend.style.left = parseInt(zhend.style.left) - rector;
}
else {
zhend.style.left = parseInt(zhend.style.left) - rector;
}
if(a < 4)
a++;
else
a = 1;
settimeout('rattleimage()', 50);
}
function stoprattle(which){
stopit = 1;
which.style.left = 0;
which.style.left = 0;
}
</script>
</head>
<body>
<img src="test.png" class="zhendimage" onMouseover="init(this);rattleimage()" onmoouseout="stoprattle(this)" />
</body>
</html>

3、自由切换图像:

<!doctype>
<html>
<head>
<meta charset='utf-8'>
<script type='text/javascript'>
var img = new array(3);
var nums = 0;
if(document.images){
for(i = 1; i <= 3; i ++){
img[i] = new image();
img[i].src = 'images/00' + i + '.png';
}
}
function fort(){
nums ++;
document.images[0].src = img[nums].src;
if(nums == 3)
nums = 0;
}
function slide(){
setInterval('fort()', 1000);
}
</script>
</head>
<body onload="slide()"> </body>
</html>

JavaScript简单的实例应用的更多相关文章

  1. Javascript DOM操作实例

          最近在学DOM,但是还是没有办法很好的记住API,想找些例子来练习,网上的例子将一个个DOM对象方法挨个举例,并没有集合在一起用,效果不尽人意.所以自己写一份实例,顺便巩固下学到的知识. ...

  2. Google Map JavaScript API V3 实例大全

    Google Map JavaScript API V3 实例大全 基础知识 简单的例子 地理位置 语言 位置 坐标 简单的投影 事件 简单事件 关闭事件 多次添加事件 事件属性 控制 php禁用ui ...

  3. 原生Ajax用法——一个简单的实例

    Ajax全名(Asynchronous(异步) JavaScript and XML )是可以实现局部刷新的 在讲AJax之前我们先用简单的实例说一下同步和异步这个概念 /*异步的概念(就是当领导有一 ...

  4. 纯JSP简单登录实例

    记一下,免得以后忘记了,又要去查. 文件共有四个web.xml.login.jsp.logout.jsp.welcome.jsp四个文件 测试环境:Tomcat 6.0.x 假设项目名称是LoginS ...

  5. ASP.NET MVC 4 插件化架构简单实现-实例篇

    先回顾一下上篇决定的做法: 1.定义程序集搜索目录(临时目录). 2.将要使用的各种程序集(插件)复制到该目录. 3.加载临时目录中的程序集. 4.定义模板引擎的搜索路径. 5.在模板引擎的查找页面方 ...

  6. Linux简单程序实例(GNU工具链,进程,线程,无名管道pipe,基于fd的文件操作,信号,scoket)

    一, GNU工具链简介: (1)编译代码步骤: 预处理 -> 编译 -> 汇编 -> 链接: 预处理:去掉注释,进行宏替换,头文件包含等工作: gcc -E test.c -o te ...

  7. Redis:安装、配置、操作和简单代码实例(C语言Client端)

    Redis:安装.配置.操作和简单代码实例(C语言Client端) - hj19870806的专栏 - 博客频道 - CSDN.NET Redis:安装.配置.操作和简单代码实例(C语言Client端 ...

  8. MVC 4 插件化架构简单实现实例篇

    ASP.NET MVC 4 插件化架构简单实现-实例篇   先回顾一下上篇决定的做法: 1.定义程序集搜索目录(临时目录). 2.将要使用的各种程序集(插件)复制到该目录. 3.加载临时目录中的程序集 ...

  9. 分布式搜索ElasticSearch构建集群与简单搜索实例应用

    分布式搜索ElasticSearch构建集群与简单搜索实例应用 关于ElasticSearch不介绍了,直接说应用. 分布式ElasticSearch集群构建的方法. 1.通过在程序中创建一个嵌入es ...

随机推荐

  1. nginx 学习资料

    nginx 学习资料 table th:first-of-type { width: 90px; } table th:nth-of-type(2) { } table th:nth-of-type( ...

  2. Hanlp分词实例:Java实现TFIDF算法

    算法介绍 最近要做领域概念的提取,TFIDF作为一个很经典的算法可以作为其中的一步处理. 关于TFIDF算法的介绍可以参考这篇博客http://www.ruanyifeng.com/blog/2013 ...

  3. Eclipse安装插件的“最好方法”:dropins文件夹的妙用

    在Eclipse3.4以前安装插件非常繁琐. 在Eclipse3.5以后插件安装的功能做了改进.而且非常方便易用. 我们只需要把需要的插件复制(拖放)到eclipse\dropins,然后插件就安装成 ...

  4. Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(

    application.class要放在根目录下,否则会发生以下错误

  5. mha error

    MasterFailover.pm 1473 $ret =1474 $_server_manager->change_master_and_start_slave( $target, $late ...

  6. WPF Demo14 依赖属性

    using System.Windows; namespace DependencyPropertyDemo1 { public class Student:DependencyObject { pu ...

  7. “无法获得锁 /var/lib/dpkg/lock -open (11:资源暂时不可用)”的方法

    另外的ubuntu 问题 在更新的时候有时候会出现 “无法获得锁 /var/lib/dpkg/lock -open (11:资源暂时不可用)”的方法 解决办法: 在ubuntu系统的termial下, ...

  8. C++进阶--模板及关键字typename

    //############################################################################ /* * 模板介绍 */ //函数模板 t ...

  9. JGit与远程仓库链接使用的两种验证方式(ssh和https)

    JGit是使用JAVA的API来操控Git仓库的库,由Eclipse公司维护.他提供的API分成两个层次,底层命令和高层命令.底层API是直接作用于低级的仓库对象,高层的API是一个面向普通用户级别功 ...

  10. Windump教程-参数介绍

    1 应用 Windump是tcpdump的Windows版本,主要的参数如下: -D 列出所有的接口 -i interface 指定用于抓包的接口 -c packetcount 指定抓包的个数 -w ...