JavaScript 生成 table
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test</title>
<mce:style type="text/css"><!--
.table_back{width:480px;height:480px;border-bottom:1px solid black;border-right:1px solid black;}
.floor{border-left:1px solid black;border-top:1px solid black;font-size:1px;}
--></mce:style><style type="text/css" mce_bogus="1"> .table_back{width:480px;height:480px;border-bottom:1px solid black;border-right:1px solid black;}
.floor{border-left:1px solid black;border-top:1px solid black;font-size:1px;}
</style>
</head>
<body>
<a href="javascript:init(11);" mce_href="javascript:init(11);">test</a>
<mce:script type="text/javascript"><!--
function init(data) {
var self = this;
this.rowCount = self.rowCount || 20;
this.colCount = self.colCount || 20;
this.parent1 = self.parent1 || document.body; // ??
this.table_back = document.createElement("table");
this.table_back.className = 'table_back';
for (var i = 0; i < this.rowCount; i++) {
var tr = this.table_back.insertRow(-1);
for (var j = 0; j < this.colCount; j++) {
var td = tr.insertCell(-1);
td.className = "floor";
td.innerHTML = " ";
}
}
this.parent1.appendChild(this.table_back);
}
// --></mce:script>
</body>
</html>
相关文档:
在JavaScript中利用document.referrer可以获得跳转前上一页的地址,其实在诸如Asp,PHP等语言中都可以获得这个参数,只不过写法不同,然后可以判断是哪里来的请求从而做一些处理.但是JS中的document.referre只能获得<a>标签传过来的参数.看代码
a.html
<html>
<head>
<title>测试</title> ......
1.创建节点并添加内容:使用的方法:createElement和createTextNode
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML DOM</title>
&nbs ......
看了很多javascrip代码,发现很多地方用到了this这个对象,那这个到底是什么东西阿?
先让我们来理解一个概念:
在javascript会有一个上下文的概念,任何一个对象无论是Object 还是function 都会有一个专有的上下文对象,也可以理解为它自己的拥有者。
那么我们很容易想到这个拥有者,必然有个终点,那就是window对象。
......
代码示例
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<mce:style><!--
.man{ float:left; background:#9af; margin:3px; padding:3px; cursor:default}
--></mce:style>< ......
通过分析各类浏览器的userAgent信息,不难得出分辨各类浏览器及其版本的正则表达式。而且,对浏览器类型的判断和版本的判断完全可以合为一体地进行。于是,我们可以写出下面的代码:
<script type="text/javascript">
  ......