惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
Know Your Adversary
Know Your Adversary
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
P
Privacy & Cybersecurity Law Blog
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
Project Zero
Project Zero
L
LangChain Blog
N
News and Events Feed by Topic
博客园 - Franky
Last Week in AI
Last Week in AI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
月光博客
月光博客
博客园_首页
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
Latest news
Latest news
WordPress大学
WordPress大学
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Spread Privacy
Spread Privacy
Attack and Defense Labs
Attack and Defense Labs
量子位
L
LINUX DO - 热门话题
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
L
Lohrmann on Cybersecurity
aimingoo的专栏
aimingoo的专栏
T
Troy Hunt's Blog
Security Latest
Security Latest
小众软件
小众软件
Cloudbric
Cloudbric
Hacker News: Ask HN
Hacker News: Ask HN
S
Secure Thoughts
雷峰网
雷峰网
T
Threat Research - Cisco Blogs
H
Hacker News: Front Page
IT之家
IT之家
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - nect

【转】ie9 rc版软件兼容问题 [z]前端设计IE6/IE7/IE8/IE9/FF问题汇总:IE和FirFox兼容问题 - nect - 博客园 [z]JS在IE和FF下attachEvent,addEventListener学习笔记 - nect - 博客园 WinForm使用webclient通过http的POST方式上传文件 转:另类解决:“ScriptManager”不是已知元素。原因可能是网站中存在编译错误。 - nect - 博客园 转:css妙用1-用图片替换文字 .net中的正则表达式(一)——转义字符 使用Cascadingdropdown控件遇到的一个问题 IP地址匹配算法 服务器控件的客户端验证脚本 从一个字符串中Remove另一个字符串 gridview 中模板列无法响应row_command事件 - nect - 博客园 在asp.net Atlas中调用 Web Service时无法找到自定义的Web Service对象的可能原因 【转】Prototype.js开发笔记//mark一下 在GridView中使用邮件链接 【转】ASP.net2。0中解决无法获取 GridView 隐藏列值问题 GridView 中格式化整理 [转]操纵自如--页面内的配合与通信 [导入]Java调用.net的WebService
[z]ie和FF 在insertRow和insertCell的区别
nect · 2010-10-15 · via 博客园 - nect

在ie和FF中 insertRow和insertCell有着一个小小的区别,

有ie中可以这样调用:

var bgame_table = document.getElementById('game_table');
nowTR = bgame_table.insertRow();

nowTD = nowTR.insertCell();

但在ff中,上面这样调用就会报错了:

FF和ie都可以这要调用:

var bgame_table = document.getElementById('game_table');
nowTR = bgame_table.insertRow(-1);

nowTD = nowTR.insertCell(-1);

-1代表什么意思呢?

原来-1代表:插入(行)单元格到 cells(rows) 集合内的最后一个。

ie默认值了-1,但FF就没有默认值的。

所以为了兼容性好,我建议大家都是加上-1

例子:

<html>
<script>
function testinsert(){
var bgame_table = document.getElementById('game_table');
nowTR = bgame_table.insertRow(-1);
with(nowTR){
nowTD = insertCell(-1);

nowTD.className = 'b_hline';
nowTD.innerHTML ="00聯盟";

nowTD = nowTR.insertCell(-1);
nowTD.align = 'left';
nowTD.innerHTML ="1111a---队 b 队 了";

nowTD = nowTR.insertCell(-1);

nowTD.align = 'left';
nowTD.innerHTML ="222 b 队 了";

nowTD = nowTR.insertCell(-1);

nowTD.innerHTML ="3333a---队 了";

nowTD = nowTR.insertCell(-1);

nowTD.innerHTML ="4444a---队 了";

}

nowTR2 = bgame_table.insertRow(-1);
with(nowTR2){
nowTD = insertCell(-1);

nowTD.className = 'b_hline';
nowTD.innerHTML ="00聯盟";

nowTD = nowTR2.insertCell(-1);
nowTD.align = 'left';
nowTD.innerHTML ="1111a---队 b 队 了";

nowTD = nowTR2.insertCell(-1);

nowTD.align = 'left';
nowTD.innerHTML ="222 b 队 了";

nowTD = nowTR2.insertCell(-1);

nowTD.innerHTML ="3333a---队 了";

nowTD = nowTR2.insertCell(-1);

nowTD.innerHTML ="4444a---队 了";

}
}
</script>
<body onload="testinsert()">
<table id="game_table" width="526" border="0" cellspacing="1" cellpadding="0" class="b_tab" >
<tr class="b_tline_fu">
<td width="40" >時間</td>
<td width="200">主客a</td>
<!--<td width="40">suyi</td>-->
<td width="110" nowrap>foot</td>
<td width="110" nowrap>大小</td>
<td width="50">單雙</td>
</tr>
</table>
</body>

</html>