[英]JavaScript, onclick-event not responding
我希望得到一個簡單而直接的答案,因為這使我發瘋。 我知道這不是執行此操作的最佳方法,但是我不知道為什么這兩行的行為會有所不同:
第一行,工作正常:
<img id="hellig_del42736" src="../images/kryds.png" title="Slet helligdagen den 01-01-2017..." alt="Slet helligdagen den 01-01-2017..." onclick="if(confirm('Vil du slette helligdagen den 01-01-2017?')){document.getElementById('helligid42736').style.textDecoration='line-through';hasChanged=false;window.location.href='/admin/admin.asp?vacfrom='+(25569+(new Date(document.getElementById('feriefra').value).getTime()/1000/86400))+'&delbankhd=42736&page=2&sid=feriefra'}" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor=''">
如果調試(F12)打開,則第二行不響應-有時會導致“ member not found-error”(成員未找到錯誤)-有時可以工作:
<img id="blockedip_del8" src="../images/kryds.png" title="Fjern blokeringen af IP# 5.6.7.8 (mail@mail.dk)..." onclick="if(confirm('Vil du fjerne blokeringen af IP# 5.6.7.8 (mail@mail.dk)?')){document.getElementById('blockid8').style.textDecoration='line-through';hasChanged=false;window.location.href='/admin/admin.asp?delblockedip={93F17D3B-7FA1-48F1-8792-K52E30273818}&page=5&sid=deadlinetime'}" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor=''">
我已經在comfirm()語句(第二行)中嘗試了幾件事:
就我所知,這些行在代碼方面是相同的,但它們的行為卻有所不同。
我知道我可以將所有語句放在一個函數中,並且“我真的不應該...”但是如果這是我想要的方式,該如何解決呢?
謝謝,
我是個白痴!
由於某種愚蠢的原因,我在同一表單內的表單元素上使用了id =“ confirm”,並將保留字更改為id =“ confirmation”解決了所有問題。
我以為我檢查了所有東西,但沒有檢查。 僅一個接一個地刪除元素並進行測試才導致錯誤。
感謝“ idmean”為我指出了周圍的代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.