JavaScript onClick does not work in Firefox

前端 未结 2 1788
日久生厌
日久生厌 2021-01-23 19:15

I have a confirmation popup that opens when a user clicks on this link:

foo

here is the r

2条回答
  •  余生分开走
    2021-01-23 19:50

    I think what you might be experiencing is a problem with the uppercase C in onClick. Try changing it to onclick (all lowercase).

    See this question: onclick or onClick?

    Also you may have trouble accessing the event object: Access global event object in Firefox

    But it the case of your example I don't think you will need it.

    event.preventDefault prevents the browser trying to follow a href of a link when it is clicked (you don't have an href in your example). If the link gets followed, and your browser navigates to another page you will not get a chance to see any error that may have happened and it can be very frustrating to work out what is going on, so if you do need to use event.preventDefault make sure it is on the first line of the function it is in

提交回复
热议问题