« | September 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | | | | |
| 公告 |
Seeking somebody... |
Blog信息 |
blog名称:竹,劲竹;刀,快刀 日志总数:17 评论数量:26 留言数量:0 访问次数:206065 建立时间:2005年6月8日 |

| |
[工作·学习]也许是,也许不是:IE's BUG 软件技术
竹刀 发表于 2006/4/7 19:47:45 |
当把一个元素的innerHTML属性赋值为<p><hr>的时候,报未知的运行时错误。
看代码吧。处理的方法来自于FF.
另外,发现使用script动态赋innerHTML时,p元素的嵌套似乎也有问题.不过,p元素本不该嵌套吧.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> Test </TITLE><META contenttype="text/html;chartset="UTF-8"><SCRIPT>function test(divId,testText){ var divEle = document.getElementById(divId); try{ divEle.innerHTML = testText; }catch(e){ divEle.innerHTML = "Error:" + e.description; } }</SCRIPT></HEAD>
<BODY>test1:<p><hr><br><div id="testDiv1" style="background-color:#FFEECC;width:50%"></div><br><br>
test2:testText<p><hr><br><div id="testDiv2" style="background-color:#FFEECC;width:50%"></div><br><br>
test3:<p>testText<hr><br><div id="testDiv3" style="background-color:#FFEECC;width:50%"></div><br><br>
test4:<p>testText<hr><br><div id="testDiv4" style="background-color:#FFEECC;width:50%"></div><br><br><script>var testText = "<p><hr>";test("testDiv1",testText);
testText = "testText<p><hr>";test("testDiv2",testText);
testText = "<p>testText<hr>";test("testDiv3",testText);
testText = "<p><hr>testText";test("testDiv4",testText);</script><div style="height:1;width:50%;"></div>[p]元素的嵌套测试.<br>直接嵌套:<br>test5:<p><p>test</p>Text</p><br><div id="testp1" style="background-color:#FFEEDD;width:50%"><p>test<p>Text</p></p></div><br>通过script动态赋值:<br>test6:<p><p>test</p>Text</p><br><p id="testp2" style="background-color:#FFEEDD;width:50%">testp</p><script>test("testp2","<p><p>test</p>Text</p>");</script></BODY></HTML> |
|
|