Solved

What is the difference between onclick and onclientclick in javascript?

Posted on 2013-06-30
4
663 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
Comment Utility
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
Comment Utility
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 35

Accepted Solution

by:
Miguel Oz earned 250 total points
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now