473,805 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onunload event handler not firing

banning
42 New Member
Expand|Select|Wrap|Line Numbers
  1. <!-- Google maps has a tendency to wreck things.  Load it LAST!  It can interfere with other stuff loading -->
  2. <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAArSHIvK5GjeMNDX4RccZ9MhQrmFaz44GnQXOo27J3f2GHeKYI9xTi9qFD_LdIDqtpRDvM4YWE8kto-A" type="text/javascript"></script>
  3.  
  4. <script type='text/javascript'>
  5.     function setImage() {
  6.         document.getElementById('eventLogoDiv').innerHTML='<a href="http://www.doughxpress.com/staging"><img src="http://www.doughxpress.com/staging/imgs/headerLOGO.jpg" alt="HIX Corporation"></img></a>';
  7.     }
  8. </script>
  9.  
  10. </head>
  11.  
  12. <body onload='setImage()' onunload='GUnload()'>
  13.  
  14.  
ok so there is the code... however the function in the onunload position wont work whenever i have onload in the body tag with it... can anyone explain to me why this is so? and maybe if you could help me with a work around would be great i tried throwing the onload in a frameset tag and an image tag and.. well the image tag worked kind of but i read in some places that onload in an image tag is not reliable.
Aug 8 '07 #1
8 4118
pbmods
5,821 Recognized Expert Expert
Heya, banning. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as, 'I need help' actually get FEWER responses?).
Aug 8 '07 #2
banning
42 New Member
Heya, banning. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as, 'I need help' actually get FEWER responses?).

code tags? sorry i didnt read the thing i just needed help real quick this is my first time ever posting on a forum.. i can usually find what ineed just reading other ppls questions
Aug 8 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, banning.

We're glad you're here, and I hope you find the help you are looking for.

Please follow the posting guidelines when posting to this site. Thanks!
Aug 8 '07 #4
banning
42 New Member
is my post ok the way it is right now? or am i still missing some guidlines? or where you just letting me know for future reference?
Aug 8 '07 #5
johnhjohn
43 New Member
The reason why the onunload event is not firing might be because there is an error in your function GUnload() or another function within the same script tag. For example:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  <head>
  3.   <script language="javascript" type="text/javascript">
  4.  
  5.    function unload()
  6.    {
  7.      alert("Page is unloading);
  8.    }
  9.  
  10.   </script>
  11.  </head>
  12.  <body onunload="unload()">
  13.  
  14.  </body>
  15. </html>
  16.  
The function unload() will not work and there are no errors on the page.
Aug 8 '07 #6
banning
42 New Member
The reason why the onunload event is not firing might be because there is an error in your function GUnload() or another function within the same script tag. For example:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  <head>
  3.   <script language="javascript" type="text/javascript">
  4.  
  5.    function unload()
  6.    {
  7.      alert("Page is unloading);
  8.    }
  9.  
  10.   </script>
  11.  </head>
  12.  <body onunload="unload()">
  13.  
  14.  </body>
  15. </html>
  16.  
The function unload() will not work and there are no errors on the page.
the onunload function i have no control over... its as function, through google, that loads google maps on my page.

One thing though that onunload fires off just fine when i dont have the onload going off with it. however the onload shouldnt effect it should it? i mean in theory onunload should still fire off even if i use the onload right?

another thing i may want to say is when i run each of the function independently they work just fine, its when i want them to both be in the body tag at the same time that the onunload throws a fit and wont load google maps.
Aug 9 '07 #7
pbmods
5,821 Recognized Expert Expert
Heya, banning.

onunload fires when the User *leaves* the page.
Aug 9 '07 #8
banning
42 New Member
Heya, banning.

onunload fires when the User *leaves* the page.

http://spongecell.com/event_page/view/418122

if you want to take a look at the source code it uses onunload to load the google maps down on the page... if you switch it to onload then it wont load the google maps... so it has to be onunload because of something that happens on googles end id guess, but i dont know. Either way onunload is staying because it has to, now why it wont play friendly with the onload is beyond me... please help meh out lol i dont get it.

and if you guys cant figure it out either its all good because i found another work around to get the result i wanted "more than one way to skin a cat" i always say.

so now im just curious why the onunload wouldnt fire when i would add the onload next to it.
Aug 9 '07 #9

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

Similar topics

3
6972
by: Laurent | last post by:
I am trying to use the onunload event to know when the user closes a popup by receiving a request on the web server. I have a main page from where the user opens a popup. What I want is when the user closes the popup, it sends a request to my web server (GoAhead) using the onunload event, then closes the popup. For the moment, this what i have: when the user closes the popup, I use the onunload event to open a different popup (by this...
4
2517
by: Roy Wang | last post by:
Hi everyone, I want to assign a url to the img.src attribute using javascript so that browser will send a request according to the url, which is all i want. The tricky stuff is i want to do it in Page OnUnload event handler which is called just before the browser is starting to unload the document(ESPECIALLY when the user choose to close the browser window to fire the event).
5
1591
by: feng | last post by:
I want to use onunload to capture user's action when he clicks on the "x" button to close the browser. Here is how I do this: <SCRIPT FOR="window" EVENT="onunload"> myScript(); </SCRIPT> While myScript() does get called when "x" gets clicked, it is also get called when the user leaves the current page and navigate to another page within our web application.
3
5879
by: =B= | last post by:
Hi all, I was wondering if anyone has had any luck with trapping the <BODY> onUnload() event in ASP.NET? The thing is, I'm writing code for an Intranet site. The code makes a call to a third-party component (think of it as a lock) when the page loads. Now the OK and Cancel server buttons I can handle and use to release the lock as required. But previously in classic ASP I had been trapping the user hitting the close 'x' button by...
4
3993
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques was endeavoring to create a custom user control to make things a bit simpler, but she noticed that her Page_Load eventhandler was firing twice. So after long hours of research and experimentation, I stumbled upon, imho, is quite the discovery. ...
1
5329
by: Laurent Bugnion | last post by:
Hi, I am trying to programatically add an "onunload" event handler to the "body" tag of an ASPX page. I am doing this from a Custom Control located on this page. To do this, I added "runat=server" to the body tag, which provides me access to it in the code-behind through a HtmlControl. I can then manipulate the Attributes collection, which is what I needed. So far so good.
1
3241
by: Kourosh | last post by:
I'm using IE6 and I've just created a simple page with this event: <body onunload="alert('sad')"> could someone tell me if this works for you if you have IE 6? I've tested this in firefox and IE 7 and they both work fine with it. but on the IE6 copy I'm testing, the event is fired only when the page is refreshed. It's not fired when I close the page.
5
2718
by: jackchang1 | last post by:
I have an application that will submit the form when the page is closed (through onunload event), and it works fine in IE6. But it doesn't work in FireFox, and no data is sent. It seems to me that FireFox doesn't let the onunload event ends before the window is closed. Or is it an form submit issue in the onunload event? Thanks!
2
3932
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever possible to make the app more efficient and less resource demanding. On one page there are 2...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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
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...
1
7646
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
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...
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

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.