Re: [問題] 關於Table 裡按按鍵的問題
: function CreatTable(){
: for( var i=0;i<sizeArray[1];i++) {
: tr = bomBody.insertRow(bomBody.rows.length);
: for( var j=0;j<sizeArray[0];j++) {
: td = tr.insertCell(tr.cells.length);
: td.id=('x'+j+'y'+i);
: td.innerHTML = ' ';
: if ( td.addEventListener )
: td.addEventListener("mousedown", SetBom, false);
: else
: td.setAttribute("onmousedown", SetBom);
: } } }
: function SetBom(onevent) {
: var onevent = onevent || window.event;
: var onLeftButton=0 , onRightButton=2 ,
: onMouseButton = onevent.button;
: //alert(onMouseButton);
: if ( onMouseButton == onLeftButton )
: onLeft(this.id);
: else if( onMouseButton == onRightButton)
: onRight(this.id);
: }
小弟本來先寫其他功能、寫完回來看發現...只要把
td.setAttribute("onmousedown", SetBom);
改成
td.attachEvent("onmousedown", SetBom);
就可以了
但是現在又有一個問題就是 在 SetBom(onevent) 收不到傳過來的 id
不知道是哪裡用錯了...還是 IE 不支援這種寫法呢? 如果是 該如何改呢?
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.160.239.183
※ 編輯: kiey 來自: 1.160.239.183 (11/10 11:43)
※ 編輯: kiey 來自: 1.160.239.183 (11/10 11:44)
→
11/10 12:48, , 1F
11/10 12:48, 1F
→
11/10 12:48, , 2F
11/10 12:48, 2F
→
11/10 12:48, , 3F
11/10 12:48, 3F
→
11/10 13:54, , 4F
11/10 13:54, 4F
→
11/10 15:55, , 5F
11/10 15:55, 5F
→
11/10 15:57, , 6F
11/10 15:57, 6F
→
11/10 16:00, , 7F
11/10 16:00, 7F
→
11/10 16:01, , 8F
11/10 16:01, 8F
→
11/10 16:09, , 9F
11/10 16:09, 9F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章