動態 HTML
应用
编辑动态HTML
客 户端脚本 客 户端脚本 包括 JavaScript技 术。是 指 在 某 个页面 中 ,通 过鼠标点击或键盘操作 ,与 网页产生交互 动作;或 者 在 特定 时间激 发某个事件 。客 户端脚本 在 用 户的电脑系 统里运行。常用 于多媒体 展示 和 远程脚本 调用。服 务器脚本 服 务器脚本 包括 ASP, ColdFusion, Perl, PHP, Ruby, WebDNA等 技 术,一般 通 过Common Gateway Interface (CGI)来 产生动态页面。通 过在HTML表 单中填 写 数 据 ,更改 URL地 址 中 的 参 数 ,更改 浏览器 的 类型等 ,每次 都 可能 产生不同 的 页面,称 之 为动态页面 。
- 产生
交互 式 表 单 生成 类似WebCT的 e-learning交互 式 在 线基础培训- 创建
基 于浏览器的 视频游 戏
結構
编辑
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DHTML example</title>
<script type="text/javascript">
function init() {
myObj = document.getElementById("navigation");
// .... more code
}
window.onload=init;
</script>
</head>
<body>
<div id="navigation"></div>
<pre>
Often the code is stored in an external file; this is done by linking the file that contains the JavaScript.
This is helpful when several pages use the same script:
</pre>
<script type="text/javascript" src="myjavascript.js"></script>
</body>
</html>
範 例
编辑
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test</title>
<style type="text/css">
h2 {background-color: lightblue; width: 100%}
a {font-size: larger; background-color: goldenrod}
a:hover {background-color: gold}
#example1 {display: none; margin: 3%; padding: 4%; background-color: limegreen}
</style>
<script type="text/javascript">
function changeDisplayState (id) {
d=document.getElementById("showhide");
e=document.getElementById(id);
if (e.style.display == 'none' || e.style.display == "") {
e.style.display = 'block';
d.innerHTML = 'Hide example..............';
} else {
e.style.display = 'none';
d.innerHTML = 'Show example';
}
}
</script>
</head>
<body>
<h2>How to use a DOM function</h2>
<div><a id="showhide" href="javascript:changeDisplayState('example1')">Show example</a></div>
<div id="example1">
This is the example.
(Additional information, which is only displayed on request)...
</div>
<div>The general text continues...</div>
</body>
</html>