ie 處理 “/>” 形式的結(jié)尾標(biāo)簽有問題。如下面這段:
<form …><table … /></form>
如果使用 javascript 向表格內(nèi)添加表單元素<input>,你會發(fā)現(xiàn)在 ie 中<form>并沒有把這些<input>包含起來。為什么呢?看看<table>元素的 innerhtml 就知道了:第一行竟然是“</form>”!可見 ie 對這種情況的處理有多糟糕。firefox下就沒有這種情況。
ie 的 dom 模型不允許設(shè)置 <table> 元素的 innerhtml。在 dhtml 參考文檔你會看到,ie 建議使用 insertrow 等方法來操作表格內(nèi)容,而使用 table.innerhtml=… 在 ie 下面就會報(bào)錯(cuò)。 firefox 沒有這個(gè)問題。
ie 的 dom 模型不能正確地創(chuàng)建單選框。如下面的 javascript 代碼:
var radio = document.createelement(‘input’);radio.setattribute(‘type’, ‘radio’);radio.setattribute(‘name’, name);radio.setattribute(“value”, value);
如果把這樣創(chuàng)建出來的單選框放到頁面上,在 ie 下這些單選框都沒法選中。firefox沒有這個(gè)問題。折中的解決辦法是:
function createradio(name, value) {if (navigator.appname.indexof(“microsoft”) != -1) {var radio = document.createelement(‘<input type=”radio” name=”‘ + name + ‘” />’);radio.value = value;return radio;} else {var radio = document.createelement(‘input’);radio.setattribute(‘type’, ‘radio’);radio.setattribute(‘name’, name);radio.setattribute(“value”, value);return radio;}}
新聞熱點(diǎn)
疑難解答
圖片精選