当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JavaScript教程:用JS脚本实现Web页面信息交互范例

Javascript
Jquery实战_读书笔记2 选择器
JQuery 确定css方框模型(盒模型Box Model)
jQuery 入门级学习笔记及源码
被jQuery折腾得半死,揭秘为何jQuery为何在IE/Firefox下均无法使用
JQuery 构建客户/服务分离的链接模型中Table分页代码效率初探
JQuery 构建客户/服务分离的链接模型中Table中的排序分析
JQuery.uploadify 上传文件插件的使用详解 for ASP.NET
JavaScript 学习笔记(十四) 正则表达式
JQuery 操作Javascript对象和数组的工具函数小结
用JS写的一个TableView控件代码
JQuery 1.4 中的Ajax问题
window.onbeforeunload方法在IE下无法正常工作的解决办法
优化javascript的执行速度
jQuery 1.4 15个你应该知道的新特性(译)
js 模拟实现类似c#下的hashtable的简单功能代码
setTimeout与setInterval在不同浏览器下的差异
php gethostbyname获取域名ip地址函数详解
JavaScript 未结束的字符串常量常见解决方法
document.getElementById为空或不是对象的解决方法
javascript中利用数组实现的循环队列代码

Javascript 中的 JavaScript教程:用JS脚本实现Web页面信息交互范例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 86 ::
收藏到网摘: n/a

要实现动态交互,必须掌握有关窗体对象(Form)和框架对象(Frames)更为复杂的知识。

三、范例

下面我们演示通过点击一个按钮(red)来改变窗口颜色,点击“调用动态按钮文档”调用一个动态按钮文档。

test8_1.htm

<html>
<head>
<Script Language="JavaScript">
//原来的颜色
document.bgColor="blue";
document.vlinkColor="white";
document.linkColor="yellow";
document.alinkcolor="red";
//动态改变颜色
function changecolor(){
document.bgColor="red";
document.vlinkColor="blue";
document.linkColor="green";
document.alinkcolor="blue";
}
</script>
</HEAD>
<body bgColor="White" >
<A href="test8_2.htm"> 调用动态按钮文档</a>
<form >
<Input type="button" Value="red" onClick="changecolor()">
</form>
</BODY>
</HTML>

输出结果见图1所示。


图1

动态按钮程序。

test8_2.htm


<HTML>
<HEAD>
</HEAD>
<p align="center"> </p>
<div align="center"><center>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><form name="form2" onSubmit="null">
<p><input type="submit" name="banner" VALUE="Submit"
onClick="alert('You have to put an \'action=[url]\' on the form
tag!!')"> <br>
<script language="JavaScript">
var id,pause=0,position=0;
function banner() {
// variables declaration
var i,k,msg=" 这里输入你要的内容";// increase msg
k=(30/msg.length)+1;
for(i=0;i<=k;i++) msg+=" "+msg;
// show it to the window
document.form2.banner.value=msg.substring(position,position-30);
// set new position
if(position++==msg.length) position=0;
// repeat at entered speed
id=setTimeout("banner()",60); }
// end -->
banner();
</script></p>
</form>
</td>
</tr>
</table>
</center></div>
<p> </p>
<BODY>
<A href="test8_1.htm"> 返回</a>
</BODY>
</HTML>

输出结果见图2所示。


图2  

  本讲介绍了使用JavaScript脚本实现Web页面信息交互的方法。其中主要介绍了窗体中的基本元素的主要功能和使用。