davej Posted December 30, 2012 Share Posted December 30, 2012 What is the significance of javascript:void(0); ??? Often I click on a link and nothing happens and I see javascript:void(0); Perhaps my host file or popup blocker has blocked it? Link to comment Share on other sites More sharing options...
jeffman Posted December 31, 2012 Share Posted December 31, 2012 (edited) Very old-fashioned code sometimes assigned the href attribute the value javascript:void(0) . This is basically a javascript statement that does nothing, so it keeps the link from behaving like a link without really doing anything else. You might also see some sort of "onclick" attribute in the tag also. None of this is good style in HTML5 (or HTML 4, for that matter). It's better to assign event handlers in the main script. It's also better to use some other element besides a link to trigger behavior that is not link-like. (It is appropriate for a link to trigger behavior before it changes the location, but not instead of that) Edited December 31, 2012 by Deirdre's Dad Link to comment Share on other sites More sharing options...
lovelmark Posted February 10, 2020 Share Posted February 10, 2020 javascript:void(0) is not a very critical error, it sure is an irritating to encounter. When you encounter the javascript:void(0) error it most probably is an indication of an error stemming from your browser; which in turn blocks you from accessing a particular website. The root cause of the error can be traced to a resident pop up blocker in your internet browser. Also, it may be triggered by a proxy server if you are connecting to the internet through proxy. The void operator evaluates the given expression and then returns undefined. If you have pass 0 as the unary expression operand to the void operator, JavaScript coerces 0 to "false" and returns, but void doesn't care and simply returns undefined, which means "do nothing" . Put them together and you have composed a way to programmatically "do nothing" when a link is clicked. JavaScript Void(0) is often used when, inserting an expression into a web page may produce an unwanted side-effect. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now