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 ?

1
  • Both are same. No Difference Commented Aug 12, 2013 at 9:25

1 Answer 1

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 )
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.