HTML的DOM操作例子
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>use html as DOM</title>
<mce:script language="javascript" type="text/javascript"><!--
function addUser() {
// get and execute name
var name = $("name").value;
if(name == "") return;
// create a new row
var row = document.createElement("tr");
row.setAttribute("id", name);
// create a new cell (name)
var cell = document.createElement("td");
cell.appendChild(document.createTextNode(name));
// add cell to row
row.appendChild(cell);
// a new cell (delete)
cell = document.createElement("td");
// dim a button
var delButton = document.createElement("input");
delButton.setAttribute("type", "button");
delButton.setAttribute("value", "delete");
delButton.onclick = function () {delUser(name)};
// add button to cell
cell.appendChild(delButton);
// add cell to row
row.appendChild(cell);
// add row to table
$("userList").appendChild(row);
// set textbox ""
$("name").value = "";
}
function delUser(name) {
$("userList").removeChild($(name));
}
function $(id) {
return document.getElementById(id);
}
// --></mce:script>
</head>
<body>
<input type="text" id="name">
<input type="button" value="add" onclick="addUser()"><p/>
<table border="1">
<thead>
<td width="100">name</td><td>delete</td>
</thead>
<tbody id="userList">
</tbody>
</ta
相关文档:
HTML中实现右键菜单功能
我们使用的应用系统很多都有右键菜单功能。但是在网页上面,点击右键一般显示的却是IE默认的右键菜单,那么我们如何实现自己的右键菜单呢?下面将讲解右键菜单功能的实现原理和实现代码。
实现原理
在HTML语言中,基本上每个对象都有一个oncontextmenu事件,这个事件就是鼠标的右键单击 ......
String.prototype.HTMLEncode = function() {
var temp = document.createElement ("div");
(temp.textContent != null) ? (temp.textContent = this) : (temp.innerText = this);
var output = temp.innerHTML;
temp = null;
return output;
}
String.prototype.HTMLDecode = function() {
var temp = doc ......
在Web开发中,常常要用到两个窗口之间互相传值。下面谈谈父子窗口之间的传值:
一:使用Open开启子窗口
1:单值传递
通过open开启的子窗口比较好处理。
页面窗口1.html代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<body>
<form name=" ......
<html>
<frameset cols="50%,*,25%">
<!-- 左边页面占50% 被固定住了 -->
<frame src="/example/html/frame_a.html" noresize="noresize"
/>
<frame src="/example/html/frame_b.html" />
<frame s ......
Teach Yourself Visually Html And CSS
Pro CSS and HTML Design Patterns
JavaScript and DHTML Cookbook 2nd Edition
The Right Way Using HTML & CSS
网页制作完全手册
HeadFirst HTM ......