0

Reading this question : What does "javascript:void(0)" mean? I can understand why <a href="javascript:void(0)" is used - in order to prevent a page redirection.

I have come across this code :

<a id="myId" href="javascript:void()"
    onclick="removePopup()">Close</a>

The operator void does not take any parameter in this case. Is this a bug ?

Community
  • 1
  • 1
blue-sky
  • 51,962
  • 152
  • 427
  • 752

1 Answers1

2

Yes, it's a bug. The browser will throw a syntax error when the link is clicked, unless the removePopup() function stops the default action. (If the function does that, it might explain why the developer didn't notice it.)

> void()
SyntaxError: Unexpected token )
JJJ
  • 32,902
  • 20
  • 89
  • 102