[問題] onreadystatechange 在 IE8 與 Firefox 4 行為不一樣

看板Web_Design作者 (我是好人,也是個壞人)時間14年前 (2011/06/14 16:46), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
showDeviceValue() 在 IE8 與 Firefox 4.0.1 的行為不一樣,有人知道為什麼嗎?... //Example Code var requests = new Object; window.onload = function(){ var buttons = document.getElementsByTagName("input"); if(buttons == null) { alert("no any button!"); return; } var re = new RegExp(/^btn(\d+)$/); for(var i = 0; i < buttons.length; ++i) { var btn = buttons[i]; matches = re.exec(btn.id); if(matches == null) continue; requests[matches[0]] = createRequest(); //XML HTTP Request requests[matches[0]].onreadystatechange = function(ev){ showDeviceValue(ev, btn, document.getElementById("td" + matches[1])); } buttons[i].onclick = refreshDeviceValue; } } function showDeviceValue(ev, btn, td) { var theEvent = ev ? ev : window.event; var theSrc = theEvent.target ? theEvent.target : theEvent.srcElement; //in Firefox 4.0.1: theSrc != null //in IE8: theSrc == null } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 223.138.33.162
文章代碼(AID): #1Dzn_mMr (Web_Design)