DevelopPHP
home Forum gear home

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting
return statement Javascript   Share / Like

The Javascript return statement is used to return a value from a function. It terminates the function from further executing code, and returns a value to the caller.

Javascript CODE EXAMPLE
function addNums(v1, v2) {

    return v1 + v2;

}
var sum = addNums(2, 3);
document.write(sum);
 

 

Here is an example using return false to disable the normal functionality of a link.

Javascript CODE EXAMPLE
<a onclick="return false" href="www.adamkhoury.com">
  Click Me
</a>
 

 

I use the following code to disable normal functionality of my link so that when I use it to enable my Javascript, the pound sign will not show up in the user address bar when they click my anchor element. Using return false as the value of the "onclick" event makes that possible.

Javascript CODE EXAMPLE
<script type="text/javascript">
function jsFunction(){
    alert("This Javascript is enabled through an html anchor element.");
}
</script>
<a href="#" onclick="return false" onmousedown="jsFunction()">
  Click Me
</a>
 
Click Me

 

Home   •   Terms of Use   •   Developer Forums   •   T-Shirts   •   RSS   •   Classroom Chalkboard   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
©2013 DevelopPHP   |   Navigate to related domains HTML5