473,769 Members | 6,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Browser Close Problem

Dear All,

I have a Main Asp.Net page . In that Page I have a Tab Strip which has
SIX tabs each representing a different web Forms.So that when a user
clicks different tab he can navigate between different forms.In my Main
Page I have written a javascript code

function ConfirmClose() {

confirm("Are you Sure You Want to Close This Main Window?") ;

}

and in the body tag of Main form I have written <body onbeforeunload
="ConfirmClose( )" >
Now this code is only for the Main Form which has a Tab Strip of SIX
different forms. Now the problem is When the Main Page is loaded
and I click X button of the browser It displays the message
("Are you Sure You Want to Close This Main Window?") which is
fine, but when I navigate to some other Form which is within the
MAIN FORM by pressing the Tab button the above message again
pops up.and it keeps poping up as I navigate through the six forms.
which I dont want. I only want this message to appear when I press
X Button of Main Browser window .

Any help much appreciated.

cheers,
Sunil Sabir
Nov 18 '05 #1
2 1668
See the documentation for the onclose event (I believe, check aslo brower
support).

onbeforeunlaod is when the current document uis unloaded. This is the case
each time you request a new page from the server...

Patrice.

--

"Sunil Sabir" <Su********@dis cussions.micros oft.com> a écrit dans le message
de news:E4******** *************** ***********@mic rosoft.com...
Dear All,

I have a Main Asp.Net page . In that Page I have a Tab Strip which has
SIX tabs each representing a different web Forms.So that when a user
clicks different tab he can navigate between different forms.In my Main
Page I have written a javascript code

function ConfirmClose() {

confirm("Are you Sure You Want to Close This Main Window?") ;

}

and in the body tag of Main form I have written <body onbeforeunload
="ConfirmClose( )" >
Now this code is only for the Main Form which has a Tab Strip of SIX
different forms. Now the problem is When the Main Page is loaded
and I click X button of the browser It displays the message
("Are you Sure You Want to Close This Main Window?") which is
fine, but when I navigate to some other Form which is within the
MAIN FORM by pressing the Tab button the above message again
pops up.and it keeps poping up as I navigate through the six forms.
which I dont want. I only want this message to appear when I press
X Button of Main Browser window .

Any help much appreciated.

cheers,
Sunil Sabir

Nov 18 '05 #2
that is correct. the event fire whenever a page is unloaded, which will
happen with any navigation. there is no browser event tied to actual browser
close. you can host your site in a frameset that detects the close, which
would be closer to want you want.

-- bruce (sqlwork.com)
"Sunil Sabir" <Su********@dis cussions.micros oft.com> wrote in message
news:E4******** *************** ***********@mic rosoft.com...
Dear All,

I have a Main Asp.Net page . In that Page I have a Tab Strip which has
SIX tabs each representing a different web Forms.So that when a user
clicks different tab he can navigate between different forms.In my Main
Page I have written a javascript code

function ConfirmClose() {

confirm("Are you Sure You Want to Close This Main Window?") ;

}

and in the body tag of Main form I have written <body onbeforeunload
="ConfirmClose( )" >
Now this code is only for the Main Form which has a Tab Strip of SIX
different forms. Now the problem is When the Main Page is loaded
and I click X button of the browser It displays the message
("Are you Sure You Want to Close This Main Window?") which is
fine, but when I navigate to some other Form which is within the
MAIN FORM by pressing the Tab button the above message again
pops up.and it keeps poping up as I navigate through the six forms.
which I dont want. I only want this message to appear when I press
X Button of Main Browser window .

Any help much appreciated.

cheers,
Sunil Sabir

Nov 18 '05 #3

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

Similar topics

2
3222
by: ho0c1355 | last post by:
Hi, I was wondering anyone can help me? I am looking for a javascript that can do such a thing? If the Mouse and keyboard sit and do nothing for 5 to 10 minutes. The Internet Browser will close and return to the PC desktop. Thanks, Chris
34
3483
by: Charles Douglas Wehner | last post by:
This is a serious question - but probably one that has been asked many times before. Go to http://wehner.org It has FRAMES. Select ADDISON. The main page (to the right of the buttons) shows it. In ADDISON, select WHATIS. The main page switches to WHATIS.
1
8202
by: Matt | last post by:
When we refresh the page (F5, or icon in browser), it will first trigger ONUNLOAD event and then trigger ONLOAD event. When we close the browser (X on right top icon), it will trigger ONUNLOAD event. Now when ONUNLOAD event is triggered, there is no way to distinguish between refresh the page or close the browser. Here's the code fragment. The logic in window_unload() only applies to
3
1828
by: Gin Lye | last post by:
Does any one know to close the web browser automatically after logging off Your help will be appreciated gin lye
3
2244
by: Ben | last post by:
Hi, I'm sending out a session cookie. That is a cookie that has no expiration date. When I surf through the site, no problems, but if I close the browser and open it back up, the cookie is still there if other browser windows were open. Even if those windows didn't go to the site with the cookie or spawn from the browser that is visiting the site. This is causing a problem. People want to be able to close the browser to logout. How...
6
3944
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a signal to server. This seems to be achievable with body unload events, but it is little too much, as even if user navigate within my site, this event will be generated, this can be avoided by handling onclick of each link, so that I'll know exactly...
1
3077
by: SwamyKarthik | last post by:
I am building an MS Access application that has an embedded web browser in a form. The form is linked to a table and the browser navigates to the address in the table. I have used the activeX object: Microsoft Web Browser Problem: After I successfully navigate to the new URL and then close the form and try to return to normal duties, the toolbars freezes up. (I can't go from design view to query or form view...etc) I noticed this only...
0
1263
by: rehanrana | last post by:
I built application in VB6, my application appear in system tray, when I double click on icon of my application, it run screen saver, my screen saver shows images and news. Screen saver functionality is that when user press F2 key, my screen saver open news detail in browser. But the problem is that when screen saver stop (close), browser also close with the screen saver. following line i use to start screen saver lRet =...
0
9587
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
9423
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
10211
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
9863
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...
0
8870
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
7406
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
5298
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.