Javascript Void 0

Javascript void (0) is an error message that occasionally comes out in a Web browser whenever a problem arises in the loading of JavaScript from a Web page.

A hyperlink is often used to connect to information or objects located in another page. It can also be used to refresh data on the page you are currently viewing. You can use JavaScript to add functions instead of leading to another area or object. The functional action can update the sums on the Web page or dynamically update a form field.

To prevent the browser from accessing a different area or refreshing the page while the other JavaScript functions are added, a JavaScript void function can be used. Use the parameter zero (0) so that the page is not changed.

Javascript Void 0 Explanation

Web browsers will try to load all elements needed for a URL. The JavaScript void function stops loading because it gives the browser an empty value. This means that when the browser tries to load a page, the function shows an empty value.

If a JavaScript statement is used as the URL to return a value, the Web browser would try to load a page. The void function is then added to stop the load and complete the JavaScript function. One important thing to remember regarding the void operator is that it needs a value and it cannot be used by itself.

Simple JavaScript Void 0 Example

An example would be a hyperlink that should only execute a function (i.e. lead to another page) when the mouse is double-clicked. Clicking once would not cause anything to happen. You can stipulate the double click detail with the use of JavaScript’s “ondblclick” method. Place the script “JavaScript: void (0)” in the anchor link so it doesn’t reload when it is clicked once.

Web browsers enable you to carry out Javascript statements directly by keying in a Javascript code into the URL Text field of the browser. You just have to place a “Javascript:” before the code to tell the browsers that you want to run Javascript.