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

推荐订阅源

SecWiki News
SecWiki News
H
Help Net Security
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
L
LangChain Blog
K
Kaspersky official blog
I
Intezer
Martin Fowler
Martin Fowler
爱范儿
爱范儿
AWS News Blog
AWS News Blog
The Hacker News
The Hacker News
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
CXSECURITY Database RSS Feed - CXSecurity.com
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
U
Unit 42
N
News and Events Feed by Topic
A
Arctic Wolf
G
GRAHAM CLULEY
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
F
Fortinet All Blogs
C
Cisco Blogs
美团技术团队
Vercel News
Vercel News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Hacker News: Front Page
T
Tailwind CSS Blog
I
InfoQ
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
P
Palo Alto Networks Blog
A
About on SuperTechFans
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
TaoSecurity Blog
TaoSecurity Blog
Google Online Security Blog
Google Online Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy & Cybersecurity Law Blog
H
Heimdal Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
O
OpenAI News
博客园 - Franky
Scott Helme
Scott Helme

博客园 - 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>