?
Solved

What is the difference between onclick and onclientclick in javascript?

Posted on 2013-06-30
4
Medium Priority
?
874 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 12

Assisted Solution

by:duttcom
duttcom earned 600 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 400 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

765 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