一个网友写的一些javascript脚本,希望大家喜欢!(转载)
来源:互联网 发布:java嵌入html 编辑:程序博客网 时间:2024/05/10 03:20
移动图片 游戏
<html>
<head>
<title></title>
<script language="javascript">
var b2=3; b1=6; a2=4; a1=2;
function moveIt()
{bbb.style.left=parseInt(bbb.style.left)-b1;
bbb.style.top=parseInt(bbb.style.top)+b2;
aaa.style.left=parseInt(aaa.style.left)+a1;
aaa.style.top=parseInt(aaa.style.top)+a2;
if
((parseInt(bbb.style.left)<-50)||(parseInt(bbb.style.left)>860))
{b1=-b1;}
if ((parseInt(bbb.style.top)<-15)||(parseInt(bbb.style.top)>490))
{b2=-b2;}
if ((parseInt(aaa.style.left)<0)||(parseInt(aaa.style.left)>800))
{a1=-a1;}
if ((parseInt(aaa.style.top)<-100)||(parseInt(aaa.style.top)>450))
{a2=-a2;}
setTimeout('moveIt()',100);
}
</script>
</head>
<body onload="moveIt()">
<div id="bbb" style="position:relative; left:20px; top:8px; width:40px;
height:16px;">
<dd><img src="book.gif" width="128" height="128"></dd>
</div>
<div id="aaa" style="position:relative; left:100px; top:8px; width:9000px;
height:16px;">
<dd><font color="#ff00ff">It'a very good!</font>
</div>
</body>
<html>
一个js的树形结构脚本
<script language="JavaScript">
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;
if (ver4) {
with (document) {
write("<STYLE TYPE='text/css'>");
if (NS4) {
write(".parent {position:absolute; visibility:visible}");
write(".child {position:absolute; visibility:visible}");
write(".regular {position:absolute; visibility:visible}")
}
else {
write(".child {display:none}")
}
write("</STYLE>");
}
}
function getIndex(el) {
ind = null;
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers;
if (whichEl.id == el) {
ind = i;
break;
}
}
return ind;
}
function arrange() {
nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;
for (i=firstInd+1; i<document.layers.length; i++) {
whichEl = document.layers;
if (whichEl.visibility != "hide") {
whichEl.pageY = nextY;
nextY += whichEl.document.height;
}
}
}
function initIt(){
if (!ver4) return;
if (NS4) {
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers;
if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
}
arrange();
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
whichEl = divColl(i);
if (whichEl.className == "child") whichEl.style.display = "none";
}
}
}
function expandIt(el) {
if (!ver4) return;
if (IE4) {
whichEl = eval(el + "Child");
if (whichEl.style.display == "none") {
whichEl.style.display = "block";
}
else {
whichEl.style.display = "none";
}
}
else {
whichEl = eval("document." + el + "Child");
if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
}
else {
whichEl.visibility = "hide";
}
arrange();
}
}
onload = initIt;
</script>
</font></p>
<div id="KB1Parent" class="parent"> <a href="#" onClick="expandIt('KB1'); return false" ><img src="img/plus.gif" border=0>文件夹一</a></div>
<div id="KB1Child" class="child"> <a href="sample.htm" target="_blank" ><img src="img/spacer.gif" border=0 alt=""><img src="img/open.gif" border=0>页面一</a><br>
<a href="sample.htm" target="_blank" ><img src="img/spacer.gif" border=0 alt="" width="15" height="11"><img src="img/open.gif" border=0>页面二</a><br>
<a href="sample.htm" target="_blank" ><img src="img/spacer.gif" border=0 alt="" width="15" height="11"><img src="img/open.gif" border=0>页面三</a></div>
<div id="KB2Parent" class="parent"> <a href="#" onClick="expandIt('KB2'); return false" ><img src="img/plus.gif" border=0>文件夹二</a></div>
<div id="KB2Child" class="child"> <a href="sample.htm" target="_blank" ><img src="img/spacer.gif" border=0 alt="" width="15" height="11"><img src="img/open.gif" border=0>页面一</a><br>
<a href="sample.htm" target="_blank" ><img src="img/spacer.gif" border=0 alt=""><img src="img/open.gif" border=0>页面二</a><br>
<a href="sample.htm" target="_blank" ><img src="img/spacer.gif" border=0 alt="" width="15" height="11"><img src="img/open.gif" border=0>页面三</a></div>
<div id="KB3Parent" class="parent"> <a href="#" onClick="expandIt('KB3'); return false" ><img src="img/plus.gif" border=0>文件夹三</a></div>
<div id="KB3Child" class="child"> <a href="sample.htm" target="_blank" ><img src="img/spacer.gif" border=0 alt=""><img src="img/open.gif" border=0>页面一</a><br>
<a href="sample.htm" target="_blank" ><img src="img/open.gif" border=0>页面二</a><br>
<a href="sample.htm" target="_blank" ><img src="img/spacer.gif" border=0 alt=""><img src="img/open.gif" border=0>页面三</a></div>
<script language="JavaScript">
if (NS4) {
firstEl = "KB1Parent";
firstInd = getIndex(firstEl);
arrange();
}
</script>
下面是 点击按钮的同时在parentframe中,装载两个页面
<HTML><HEAD><title>Frames</title></HEAD> <FRAMESET COLS="295,*"> <FRAMESET ROWS="100%,*"> <FRAME SRC="loadtwo.html" NAME="fr1"> </FRAMESET> <FRAMESET ROWS="75%,25%"> <FRAME SRC="cell.html" NAME="fr2"> <FRAME SRC="cell.html" NAME="fr3"> </FRAMESET> </FRAMESET> </HTML>
第 一 个 frame 会 载 入 loadtwo.html 并 产 生 一 个 按 钮 :
loadtwo.html
<HTML><HEAD><script language="JavaScript"><!-- Hiding function loadtwo(page2, page3) { parent.fr2.location.href=page2; parent.fr3.location.href=page3;}// --></script></HEAD><BODY><FORM NAME="buttons"> <INPUT TYPE="button" VALUE="同 时 载 入 两 份 文 件" onClick="loadtwo('frtest1.html', 'frtest2.html')"></FORM></BODY></HTML>
动态改变按钮上的文字
<html>
<body>
<input type=button name =b1 value="按钮1" onclick="abc()">
<input type=button name =b2 value="按钮2" >
<input type=button name =b3 value="按钮3">
</body>
</html>
<script language=javascript>
function abc()
{
for(i=1;i<=3;i++)
{
document.all("b"+i).value=i;
}
}
</script>
图片移动标签:
scrollAmount=2 数字越大,速度越快
direction=up 移动的方向 可以变换英文“下”“左”“右”
height=200 为移动的高度
<MARQUEE scrollAmount=2 direction=up height=200>
<P align=center><IMG src="C:/Documents and Settings/Administrator/My Documents/My Pictures/haha1.gif"></P>
欢迎光临!!!
</marquee>
<MARQUEE scrollAmount=2 direction=right height=200>
<P align=center><IMG src="C:/Documents and Settings/Administrator/My Documents/My Pictures/haha1.gif"></P>
欢迎光临!!!
</marquee>
- 一个网友写的一些javascript脚本,希望大家喜欢!(转载)
- 模仿 msn 写的一个界面程序(源码),希望大家能够喜欢
- 推荐一些好的文章,希望大家喜欢
- (推荐)一个很不错的自学视频网站,希望大家能喜欢!
- win phone开发必看资料,下载地址收藏啦!收藏后可有选择性的下载,希望大家喜欢!(转载)
- 总结分享下日常生活中用到的一些功能,很好很强大,功能很多有20个,希望大家喜欢
- 转载的,给大家分享,,希望有用
- 准备近期写一些关于RESIP开发有关的VOIP资料,希望对大家有所帮助
- 准备写一个关于C++底层实现方面的连载,希望得到大家的支持。
- 一个javascript脚本写的俄罗斯方块
- 奋斗中。。。自己写的一个时钟程序,希望大家继续完善!
- 一个失败的程序,希望大家指点
- 写了一个自定义验证控件,不足之处希望大家指出
- 给大家带来几个还不错的主题!!!希望大家喜欢哦!!!
- 使用Maven的一些小建议,希望你能喜欢
- 小弟花了两个小时整理了Php方面的一些热门资料,汇总了资料下载地址,有专题,有文档,有源码,希望大家喜欢~
- template的用法(转载)---希望对大家有用
- 分享几个主题给大家希望大家喜欢!!!
- 关于异常处理的讨论
- ASP.NET程序中常用代码汇总(二)
- 游标,存储过程,触发器的入门级helloword
- ASP.NET程序中常用代码汇总(三)
- Adodb 官方介绍
- 一个网友写的一些javascript脚本,希望大家喜欢!(转载)
- 剖析数据绑定中的DataBinder.Eval
- 为ASP.NET封装的SQL数据库访问类
- ASP.NET程序中常用代码汇总(四)
- ASP.NET程序中常用代码汇总(五)
- 认识ASP.NET配置文件Web.config
- 备忘录和便签系统的模块概要
- C++语言中用指针申请内存时产生的问题。
- MapPoint+SmartPhone+C#开发示例