473,837 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return value from event handlers necessary?

Is it necessary to return a value from the event handlers? For
instance, what does the return value in the following code signify?
What will be its impact if it returned otherwise (true)?

<a href="http://www.w3schools.c om"
onmouseover="al ert('An onMouseOver event'); return true">
<img src="Click.gif" width="100" height="30">
</a>

Apr 18 '06 #1
9 6584
Water Cooler v2 said the following on 4/18/2006 10:25 AM:
Is it necessary to return a value from the event handlers?
No. But it depends on what you are trying to do with the event handler
and what the elements default behavior is. Not returning true or false
from an onsubmit handler defeats the purpose of using it. But returning
true/false from the onclick of a Button element wouldn't serve any purpose.
For instance, what does the return value in the following code signify?
What will be its impact if it returned otherwise (true)?
Put two links on a page, one with return true and one with return false.
Then mouse over them and see what is different.
<a href="http://www.w3schools.c om"
onmouseover="al ert('An onMouseOver event'); return true">
<img src="Click.gif" width="100" height="30">
</a>


<a href="http://www.w3schools.c om"
onmouseover="al ert('An onMouseOver event'); return true">
<img src="Click.gif" width="100" height="30">
</a>
<a href="http://www.w3schools.c om"
onmouseover="al ert('An onMouseOver event'); return false">
<img src="Click.gif" width="100" height="30">
</a>

And then mouseover them and observe the browser. Nothing better than
testing code to see what it does :)

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 18 '06 #2
Thanks for your reply, Randy.

I'd done that before I posted this question. I didn't observe any
difference and my question was perhaps leaning towards, "what are the
events where the return value is significant?"

Apr 18 '06 #3
Water Cooler v2 said the following on 4/18/2006 11:26 AM:
Thanks for your reply, Randy.
Thanks for quoting next time :)
I'd done that before I posted this question. I didn't observe any
difference and my question was perhaps leaning towards, "what are the
events where the return value is significant?"


onclick of a link -
return true allows navigation after the code is executed.
return false cancels navigation after the code is executed.

onsubmit of a form
return true allows submission of the form.
return false cancels submission of the form.

That is two quick one's off the top of my head.

General Rule:
return true - allows default action of the element.
return false - cancels default action of the element.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 18 '06 #4
Thanks a big bunch, Randy. How do I rate this topic?

Apr 18 '06 #5
> return true allows navigation after the code is executed.
return false cancels navigation after the code is executed.


Just another tiny bit: what do you mean by "navigation " here?

Apr 18 '06 #6
On 18/04/2006 17:07, Water Cooler v2 wrote:
Thanks a big bunch, Randy. How do I rate this topic?


Please realise that you are posting to Usenet. Google Groups is just an
interface to it, and a substandard one at that.

You've been pointed to information about using Google Groups properly in
previous threads. The group FAQ also has detailed information about
posting to this group. Please read them, both. Whether you realise it or
not, it does benefit both you and the rest of us.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Apr 18 '06 #7
Thanks, Mike. I'll try and look up the FAQ. Could you please suggest a
good newsreader. I use both IE 6 and Firefox 1.5. I also have RSSBandit
and Awasu for RSS feeds, but I am not sure if they read newsgroups and
I'll be able to rate posts with them.

Apr 18 '06 #8
On 18/04/2006 20:37, Water Cooler v2 wrote:
I'll try and look up the FAQ.
Parts of it are posted to this group every Monday, Wednesday, and
Friday, and include links to the full document:
<http://www.jibbering.c om/faq/>
Could you please suggest a good newsreader.
In no particular order: Thunderbird, Mozilla, Forte, Gravity, XNews, and
KNode. They're all newsreaders that I've used at one time or another.
There are plenty of others (for all platforms).
I use both IE 6 and Firefox 1.5.
A browser is not necessary to use Usenet.

Does your ISP provide a news (NNTP) server? That's a more important
question.
[...] I am not sure if they read newsgroups and I'll be able to
rate posts with them.

^^^^^^^^^^
There is no concept of post ratings in Usenet (nor is there much value
in such a feature).

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Apr 18 '06 #9
Water Cooler v2 said the following on 4/18/2006 12:11 PM:

Group FAQ: http://jibbering.com/faq

Please quote what you are replying to.

If you want to post a followup via groups.google.c om, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
<URL: http://www.safalra.com/special/googlegroupsreply/ >
return true allows navigation after the code is executed.
return false cancels navigation after the code is executed.


Just another tiny bit: what do you mean by "navigation " here?


Changing the page you are viewing - at it's simplest.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 19 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
2435
by: strout | last post by:
function F(e) { return function(){P(e)} } Can anybody tell me what the code is doing? If return another function all in a function I would do function F(e)
6
5805
by: Alex Bink | last post by:
Hi, I have a validating event on a textbox in which I want to prevent the user to leave the textbox without entering the right data. Only if he clicks on another specific control he is allowed to leave the textbox without entering the right information. Is there a way to determine which other control was clicked in the validating event of the textbox? Thanks
2
1947
by: Wavemaker | last post by:
The canonical way of declaring delegates for events is to include a parameter representing the sender as well as an EventArgs derived class (or EventArgs itself) as the second parameter representing the data that accompanies the event. For example: public delegate void MessageReceivedHandler(object sender, MessageReceivedArgs e); // ...
5
2070
by: Edward Diener | last post by:
I am gathering from the documentation that return values from __events are not illegal but are frowned upon in .NET. If this is the case, does one pass back values from an event handler via "in/out" or "out" parameters ? Or is it simply that events are just notifications and are not interested in any values which event handlers might be able to return ? If the latter is the case, the event model in .NET appears to have a great...
6
1505
by: Jacky Luk | last post by:
I want to include some code for the MouseDown Event. I would like to add this for the formview or a picturebox, how come there are no messages for me to choose from. Even I created a button, no messages are shown in the pick dialog box....any help is appreicated Thanks jack
13
3528
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the following issues still exist. The article shows how to find methods on a receiver that match the pattern OnXXXX given the sender. It loops through the sender events and tries to get methods from the receiver that match the pattern. For each one...
6
2284
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to the same method (aka delegate?). I use the Tag property within this method to determine what user action is taking place. Very simple: When adding toolbar button: tbButton.Click += new...
3
2744
by: Z.K. | last post by:
I have a problem trapping the return key. I thought if I added the forms keydown event handler that this would do what I want. It did not even go into the keydown event handler when I pressed return. I have a form and three buttons. I assigned one button to the cancel button and another to the accept button property. But the right button rarely gets activated unless it just happens to have focus. So, I thought maybe I need to trap the...
3
2166
by: =?Utf-8?B?RWR3aW4=?= | last post by:
Hello Everyone. Below is the code that is in question. --- BEGIN CODE WITHIN INHERITED FORM --- protected virtual void OnFormClosing(object sender, FormClosingEventArgs e) { switch (e.CloseReason) { case CloseReason.UserClosing: if (this.AskUserIfOkayToClose() == true) { this.ExecuteApplicationCloseProcedures(); }
0
9685
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10580
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10634
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10277
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7817
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7007
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5674
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5853
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.