472,351 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

How do I apply two functions to the same event handler?

1
Currently I have onBeforeUnload with a certain function being activated within my page. On one of my pages I need to apply another function onto onBeforeUnload, so that both functions will upload. I've been using:

Expand|Select|Wrap|Line Numbers
  1. var objBody = document.body;
  2. var oldEventHandler = objBody.onBeforeUnload
  3. objBody.onBeforeUnload = function() { oldEventHandler(); test(); }
  4. //test is a function elsewhere.
  5.  
The main problem I am facing is I can't seem to be able to get to the body's true onBeforeUnload. When i bring up the body within Visual Studio and I look at the array I cannot find my previous function applied to onBeforeUnload anywhere.

Any suggestions?

Thank you,

Holy
Dec 11 '07 #1
2 1207
function beforebefore()
{
func1();
fun2();
}

objBody.onBeforeUnload = beforebefore();


Currently I have onBeforeUnload with a certain function being activated within my page. On one of my pages I need to apply another function onto onBeforeUnload, so that both functions will upload. I've been using:

Expand|Select|Wrap|Line Numbers
  1. var objBody = document.body;
  2. var oldEventHandler = objBody.onBeforeUnload
  3. objBody.onBeforeUnload = function() { oldEventHandler(); test(); }
  4. //test is a function elsewhere.
  5.  
The main problem I am facing is I can't seem to be able to get to the body's true onBeforeUnload. When i bring up the body within Visual Studio and I look at the array I cannot find my previous function applied to onBeforeUnload anywhere.

Any suggestions?

Thank you,

Holy
Dec 11 '07 #2
acoder
16,027 Expert Mod 8TB
Currently I have onBeforeUnload with a certain function being activated within my page. On one of my pages I need to apply another function onto onBeforeUnload, so that both functions will upload.
Use addEventListener/attachEvent - see link.
Dec 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dominic | last post by:
Just in case someone is interested. I came up with this solution since my previous posting. Maybe you've got some other ideas or critcism. I'll...
2
by: George Hester | last post by:
In my neck of the woods functions usually have arguments. For example f(r) = 3 + r is a nice function. f(5) = 8, f(-3) = 0. In JavaScript we could...
2
by: Mitch | last post by:
I am hosting a web browser ctl in a container that implements the IDocHostUIHandler interface. I'm using this to control the context menu.This...
1
by: Simon Harris | last post by:
Hi All, I'm new to asp.net (Migrating from 'Classic' ASP) I'm having troubles working out classes, functions etc... Current situation is...
10
by: Emre Sevinc | last post by:
Take a look at the following snippet: <html> <head> <script> function add(elementId) { var container = document.getElementById(elementId);...
5
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i was wondering if the following code snippet from a 1.1 exerpt still apply in asp.net 2.0 framework: #region Web Form Designer...
7
by: pronerd | last post by:
Does any one know how to add a function to an event handler with out losing the current event handler? For example you can add multiple functions...
2
by: Ahmed | last post by:
Ok i understand the fact that once events are raised they are executed on another thread and have no access to member functions or variables...
7
by: Christopher Pisz | last post by:
My problem is my derived class is getting called twice instead of the base and then the derived. I thought this was the purpose for virtuals and...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.