473,805 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there any idea how to prevent the next event to happen?

I attach an Event in document.onkeyu p and another event in
document.onbefo reunload

in onkeyup event, if the condition is satisfied, i will activate sth,
then i don't want the onbeforeunload event to happen.

is it possible to accomplish this?

thanks!

Apr 7 '06 #1
3 1970
wrote on 07 apr 2006 in comp.lang.javas cript:
I attach an Event in document.onkeyu p and another event in
document.onbefo reunload

in onkeyup event, if the condition is satisfied, i will activate sth,
then i don't want the onbeforeunload event to happen.

is it possible to accomplish this?


In general the "event" in the sense of a key or mouse action can only be
prevented by forcefully restraining the user. ;-)

You can however acccomplsh your aim by changing the execution to a non
execution. [Not to a non-event]

var preventive = false;

function oneventOnkeyup (){
preventive = true
// do what you want with this event;
}

function oneventOnbefore unload(){
if (preventive) return;
// do what you want with this event;
}

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 7 '06 #2
so*********@gma il.com wrote:
I attach an Event in document.onkeyu p and another event in
document.onbefo reunload

in onkeyup event, if the condition is satisfied, i will activate sth,
then i don't want the onbeforeunload event to happen.

is it possible to accomplish this?


That would depend on what you call "attach an Event". It is possible to
prevent the _event listener_ from being called (that is not preventing the
event from happening), by assigning `null' to the event handler property
if the event listener was assigned with `targetObject.o nbeforeunload =
functionObjRef; ':

targetObject.on beforeunload = null;

Or IE-only, if the event listener was assigned to the target object for the
event with targetObject.at tachEvent("onbe foreunload", functionObjRef) :

targetObject.de tachEvent("onbe foreunload", functionObjRef) ;

(There is no mention of a standards compliant `beforeunload' event yet,
so the methods of W3C DOM Level 2 Event should not apply, and it is
error-prone to use them here.)

Another approach is to set a flag to prevent pieces of code in the event
listener from being executed, but the event listener will be called anyway.
PointedEars
Apr 7 '06 #3
so*********@gma il.com wrote:
I attach an Event in document.onkeyu p and another event in
document.onbefo reunload


Is onbeforeunload a standard event? Best I can tell, it's IE specific...

Apr 10 '06 #4

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

Similar topics

4
16667
by: Simon Wigzell | last post by:
Is there a way to prevent a form submitting when you press enter on a text field? Some people press enter when they finish typing in a text field out of habit I guess unconcsciously thinking it will take them to the next field. Instead it submits the form and this causes all kinds of problems in my case. Any javascript solution?
4
12340
by: Chris | last post by:
Hi, I think I'm having some problems here with garbage collection. Currently, I have the following code: public struct Event { public int timestamp;
24
7711
by: Charles Law | last post by:
When I click a button I don't want the click event to fire. Is this possible? In fact, what I would really like is to be able to intercept the click event, perform some action, and then prevent the click from passing through to the button. Any help or suggestions much appreciated. Charles
0
952
by: Billy | last post by:
Anyone know if this a bug in VB.NET 2002 and how to overcame that situation? I have a MDI form from where I call MDI child form like that: Dim frm As New frmChild() frm.MdiParent = Me frm.Show() On that child form I have some textboxes. When form show up Leave event
15
2934
by: Billy | last post by:
Anyone know if this a bug in VB.NET 2002 and how to overcame that situation? I have a MDI form from where I call MDI child form like that: Dim frm As New frmChild() frm.MdiParent = Me frm.Show() On that child form I have some textboxes. When form show up Leave event
14
2362
by: Ed Jay | last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call: function chkNum(cellname) { var str = document.getElementById(cellname).value.toString(10); if (str < 28 || str > 36) {alert("Temperature entered is out of range."); return;} } I enter data into the first textbox and move the cursor to the second textbox. The function is properly called. Since textbox2 is empty, when I
3
2299
by: Ryan Liu | last post by:
Can someone give a sample to prevent a row from being deleted in a datatable? I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work. I need verify if there other data using data in this row before actually remove it from datagrid. I can certainly control with Delete button. But if I want to allow the user to use Del key on the keyboard, I lost this kind control.
11
4257
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked. How I stop the buttons from posting back when they are clicked? Thanks
6
1918
by: Curious | last post by:
I have an arraylist used in three separate methods. In method #1 (event method), some items are removed from the arraylist if certain conditions are met; In method #2 (event method), properties of some items are modified if certain conditions are met; In method #3, it loops through each item in the arraylist without changing any item on the arraylist or removing any item from the
0
10609
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10360
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
10366
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
9185
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
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
5542
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
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4323
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
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.