Solved

What is the difference between onclick and onclientclick in javascript?

Posted on 2013-06-30
4
786 Views
Last Modified: 2013-07-02
What is the difference between onclick and onclientclick in javascript?

Both seem to be executing the functions on the client side.

<img id="myimage" onclick="changeImage()" onclientclick = "ChangeTitle()"
src="pic_bulboff.gif" width="100" height="180">

Please advise.

Thanks
0
Comment
Question by:Ricky66
4 Comments
 
LVL 12

Assisted Solution

by:duttcom
duttcom earned 150 total points
ID: 39288927
As outlined on this page - http://forums.asp.net/t/1249580.aspx

OnClick will work on server side , OnClientClick will execute on client side before control passed to server.
 
If the client side code returns TRUE then it will go to server.
 
Generally programmers use onclientclick to validate the controls like textbox,etc.
0
 
LVL 21

Assisted Solution

by:Dale Burrell
Dale Burrell earned 100 total points
ID: 39288928
AFAIK there is no onclientclick in javascript, it only exists in asp.net, where it gets rendered as onclick to the client i.e. in javascript?

What made you think it was a javascript event?
0
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 250 total points
ID: 39288931
This event(Onclientclick ) does not exist for pure html img
http://www.w3schools.com/tags/ref_eventattributes.asp
http://www.w3schools.com/tags/tag_img.asp
The Onclientclick  is simply ignored as it is an invalid attribute. For all practical purposes you only need onclick to implement your JS click event.

Note: Onclientclick only exists for asp.net controls like buttons to allow you execute JS scripts /methods before running the event server code.
0
 

Author Closing Comment

by:Ricky66
ID: 39293829
Thanks!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question