简体   繁体   English

单击事件适用于Chrome和Edge,但不适用于Firefox

[英]Click event working in chrome and edge but not in firefox

In the project I am working, I am clicking some buttons with a given id for each and I collect those id to display data in some tables. 在我正在工作的项目中,我单击一些具有给定ID的按钮,然后收集这些ID以在某些表中显示数据。 It works fine in chrome and edge but every time I used firefox the id comes back as undefined. 它在chrome和edge上都可以正常工作,但是每次我使用firefox时,id都会返回为undefined。

The code is as follow: 代码如下:

 function reply_clickGF(e) { // collect the id of the button clicked e = e || window.event; console.log(e); e = e.target || e.srcElement; var clickId = e.id; } 
 <div id="groundFloor" class="tab active"> <br> <h2>Ground Floor</h2> <div id="buttonDispGF" style=" background-image: url('img/ground floor.jpg')" onclick="reply_clickGF()"> <div id="maxTableGF"> <p> Maximum values over the last week:</p> <table style="width: 100%" class="maxTable"> <tbody> <tr> <th class="border">Sensor Type</th> <th class="border">Max Reading</th> <th class="border">Mote Id</th> </tr> <tr> <td class="border">Pir (Presence) </td> <td class="border" id="data">1</td> <td class="border" id="data">106</td> </tr> <tr> <td class="border">Magnetic (Door) </td> <td class="border" id="data">1</td> <td class="border" id="data">106</td> </tr> <tr> <td class="border">Acoustic (dB) </td> <td class="border" id="data">38.69</td> <td class="border" id="data">106</td> </tr> </tbody> </table> <div id="table"> <table id="colourCode"> <tbody> <tr> <td height="70"><svg width="50" height="40"> <circle cx="20" cy="20" r="13.5" stroke="black" stroke-width="2" fill="green"></circle> </svg></td> <td height="70">Last Reading Within 12 Hours</td> </tr> <tr> <td height="70"><svg width="50" height="40"> <circle cx="20" cy="20" r="13.5" stroke="black" stroke-width="2" fill="yellow"></circle> </svg></td> <td height="70">Last Reading Between the Last 12 to 24 Hours </td> </tr> <tr> <td height="70"><svg width="50" height="40"> <circle cx="20" cy="20" r="13.5" stroke="black" stroke-width="2" fill="red"></circle> </svg></td> <td height="70">Last Reading Over 24 Hours or no Data for This Mote</td> </tr> </tbody> </table> </div> </div> <a href="#GFDisplay" class="tooltip" style="left: 600px; top: 140px;"><input type="button" value="104" name="104" id="104" class="button" onmouseover="handler(this)" style="position: absolute; border: 2px solid black; background-color: red;"></a> <a href="#GFDisplay" class="tooltip" style="left: 530px; top: 210px;"><input type="button" value="105" name="105" id="105" class="button" onmouseover="handler(this)" style="position: absolute; border: 2px solid black; background-color: red;"></a> <a href="#GFDisplay" class="tooltip" style="left: 400px; top: 80px;"><input type="button" value="106" name="106" id="106" class="button" onmouseover="handler(this)" style="position: absolute; border: 2px solid black; background-color: green;"></a> <a href="#GFDisplay" class="tooltip" style="left: 440px; top: 120px;"><input type="button" value="205" name="205" id="205" class="button" onmouseover="handler(this)" style="position: absolute; border: 2px solid black; background-color: red;"></a> </div><br><br> <div class="buttonDisplay"> <a href="#GFDisplay"><button type="button" class="dataButton" id="displayTables" onclick="displayAllTablesGF()"> Display All Motes Data</button></a> <button type="button" class="dataButton" id="clearAll" onclick="resetGF()">Clear All</button> </div> <div id="GFDisplay"></div> </div> 

Can someone help me by giving pointers to be able to run it in all 3 browsers? 有人可以通过提供可以在所有3种浏览器中运行的指针来帮助我吗?

Solved it myself, simply added event to reply_clickGF() in my html, now it works in all 3 browser. 我自己解决了这个问题,只需将事件添加到我的html中的reply_clickGF()中,现在就可以在所有三种浏览器中使用了。

  <div id="buttonDispGF" style=" background-image: url('img/ground floor.jpg')" onclick="reply_clickGF(event)"> 

:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 点击事件在Chrome和FireFox中无法正常运行,但在IE浏览器中可以正常运行 - On Click Event is not working in Chrome and FireFox, but works fine in the IE browers JavaScript适用于IE和Edge,但不适用于Chrome和Firefox - JavaScript working on IE and Edge but not working on Chrome and Firefox JavaScript 在 Firefox、Chrome 中不起作用 - 在 IE、Edge 中有效 - JavaScript not working in Firefox, Chrome - works in IE, Edge Bootstrap 4 - 模态。 在 Edge 中工作,而不是在 Chrome 或 Firefox 中工作 - Bootstrap 4 - Modal. Working in Edge, not in Chrome or Firefox 为什么标头转换在chrome和firefox中有效,但在edge中却无效? - Why is header transition working in chrome and firefox, but not in edge? Javascript 在 Edge 中不起作用,但在 Firefox、Chrome 中很好 - Javascript not working in edge, but fine in Firefox, Chrome 事件未在Firefox中定义,但在chrome上有效 - event not defined in firefox but working on chrome 无法让 Chrome、Edge 和 Firefox 安静地执行 beforeunload 事件 - Can't make Chrome, Edge & Firefox to quietly execute beforeunload event Ajax脚本仅适用于Firefox(不适用于Chrome,Safari,Edge等) - Ajax script only working in Firefox (not working in Chrome, Safari, Edge,…) Web通知无法在chrome上运行,但在Firefox和Microsoft Edge上可以正常运行 - Web notifications is not working on chrome, but it's working fine on firefox and microsoft edge
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM