473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

alerting window while closing mainwindow using java script

121 100+
Hi,

Please help me,
Here i have a problem
When i am trying to close the main browser i need to popup a confirmation window
actually i had a code that is working on IE browser with some issues

Here is my code
[HTML]<html>
<head>
<script type='text/javascript'>
var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer")
{
function onBeforeUnloadAction(){
return "With Out Logout You Cann't Login Again!";
}
window.onbeforeunload = function(){
if((window.event.clientX<=-1) ||(window.event.clientY<=-1)){
return onBeforeUnloadAction();
alert(onBeforeUnloadAction());
}

}
}
</script>
</head>
<body >
</body>
</html>
[/HTML]
But i have a problem in above program which should not happen
1.While refreshing the browser by pressing the refresh button and pressing the back button in the IE browser.

and I should make it work on mizilla also

2. In the Mizilla browser it is not working i need to be work on this browser also

3.It should populate when and only i pressed on window close button


Please any body give me suggesion

Thanking you,
Jan 19 '08 #1
5 2376
gits
5,390 Expert Mod 4TB
hi ...

the onbeforeunload event is used by mozilla too ... so simply remove your browserdetection and it should work for both of the browsers ...

the other problem you have is tricky ... may be you could check the location.href of the window to differ between reload, back or close-actions but i'm not sure ...

kind regards
Jan 19 '08 #2
sbettadpur
121 100+
hi ...

the onbeforeunload event is used by mozilla too ... so simply remove your browserdetection and it should work for both of the browsers ...

the other problem you have is tricky ... may be you could check the location.href of the window to differ between reload, back or close-actions but i'm not sure ...

kind regards
Thanks for replay,

i am able getting the alert window while closing the window but there is one problem for me this is working on IE and Mozilla as well.

Only problem is while iam clicking the refresh button ,Back button and as well as Home button on the browser The same alert box is popuping

For this what should i do??
Please help me....
thanking you,
Jan 21 '08 #3
gits
5,390 Expert Mod 4TB
hi ...

after some more research i'm convinced that there is no possibility to capture that events that are triggered by those buttons (back, next, refresh, home). could you tell what purpose the function serves? may be we find a workaround for the problem ...

kind regards
Jan 21 '08 #4
sbettadpur
121 100+
hi ...

after some more research i'm convinced that there is no possibility to capture that events that are triggered by those buttons (back, next, refresh, home). could you tell what purpose the function serves? may be we find a workaround for the problem ...

kind regards
Hi,
Thanks for your reply,Iam sorry for the late ..

Let i will explain here deeply

i have an application which is having login page
if i have logged in into my application by successfully means with proper login information
So in my login database i have three defferent fields which are going to update or insert every time when i was logged in our logged out

in the database table i have flag. iam setting the flags based on defferent situations those are

if i loggedin,then in the databse table the flag will set with 1.
if i loggedout ,then in thedatabase tablethe flag will set with 0.

What is the purpose of flag...??
Here iam explaining
to avoid multiple logins with same user from any system...

So in this case we should compulsory logout.

If trying to close the application without logout.
At that point iam populating one window which provides to loggout from the application...
Jan 22 '08 #5
gits
5,390 Expert Mod 4TB
hi ...

in case you have set the flag you should be able to tell the user to logout explictly the next time ... and relogin him then ... it would be the same problem when he doesn't close his browser at work ... may be over the weekend ... and tries to login at home again from another machine? ...

kind regards
Jan 22 '08 #6

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

Similar topics

2
by: Sibylle Koczian | last post by:
Still trying to learn PyQt from a book about several Python GUI toolkits, I seem to learn first what doesn't work. The following small script seems to work, but after closing the window I get the...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
5
by: Shaun Pudwell | last post by:
Hi, I'm new to c# and come from a C / C++ background. My MainWindow class has a function called DrawChart. I open an MDI Child Window and want it to make a call from its class MDIChild to...
8
by: Mészáros Tamás | last post by:
Hi all, how can I set an app's main window to visible from an other application? My problem is, that I know only the handle of the other app's main process, because the application's main window...
4
by: UJ | last post by:
I am trying to do a login screen and can't figure out how to get the new window to open after I have verified the user info. I tried the following: dim win_Main as MainWindow win_Main = new...
15
by: Mahernoz | last post by:
Hi Friends, I simply want to print a report by opening a popup, calling the print function and closing the window after the user has printed the report. I have 2 functions.... in c# The...
1
by: cnsabar | last post by:
Hi I am having a problem in closing a menu window using TK module dynamically. I use the following program. use Tk; $mw = MainWindow->new; $mw->geometry("1024x768");
3
by: globalrev | last post by:
im doing this : http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/ and when closing the program the window stays up and doesnt respond. i tried adding...
11
by: V S Rawat | last post by:
using Javascript, I am opening a web-based url in a popup window. MyWin1=Window.Open(url, "mywindow") There is a form (form1) in the url in that popup window, I need to submit that form. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.