Javascript error: TypeError: 'null' is not an object (evaluating 'event.target') on safari

前端 未结 3 909
长发绾君心
长发绾君心 2021-01-27 13:26

I have difficulty on integrating my JavaScript syntax. My code is working on Internet Explorer (IE). However, I encountered a JavaScript error when running it on Safari.

3条回答
  •  鱼传尺愫
    2021-01-27 14:11

    You're missing the event variable in your function

    document.onmouseup = function hideaddrspopup (event) 
    {   
    
       if (event.srcElement.id != 'fieldName' || event.target.id != 'fieldName')
       {   
         alert(event.srcElement.id);
         alert(event.target.id);
       }
    }
    

提交回复
热议问题