HI
I am trying to use the window onunload event, so that when a user closes the window it will go and delete a text file that it uses to read contents from, so to stop my server filling up with loads of text files.
But i have problem that it will go and delete a file if i push a button as it considers moving away from that page as an onunload event.
i am trying to write the function so that it can detect wether the button has been pushed or if the window has been closed
I have written the following function - ]function deleteFile()
-
{
-
var button1 = document.getElementById('result').click=true;
-
var button2 = document.getElementById('manual').click=true;
-
if (button1||button2)
-
{
-
alert("button pushed")
-
}
-
else
-
{
-
var q = new Query();
-
if (q.file!=null)
-
{
-
if (q.url!=null)
-
{
-
var file=q.file;
-
var url = q.url;
-
var link="a url";
-
window.opener.location=link;
-
}
-
-
}
-
}
-
}
if i push the button it says the button pushed and if i close the window it says button pushed, so its obviously not working.
any ideas?
cheers
Boyindie
6 1520
This thread does not belong in the PHP forum. Should be moved to JavaScript.
Ronald
JosAH 11,448
Recognized Expert MVP
This thread does not belong in the PHP forum. Should be moved to JavaScript.
Ronald
Et voila.
kind regards,
Jos
HI
I am trying to use the window onunload event, so that when a user closes the window it will go and delete a text file that it uses to read contents from, so to stop my server filling up with loads of text files.
But i have problem that it will go and delete a file if i push a button as it considers moving away from that page as an onunload event.
i am trying to write the function so that it can detect wether the button has been pushed or if the window has been closed
I have written the following function - ]function deleteFile()
-
{
-
var button1 = document.getElementById('result').click=true;
-
var button2 = document.getElementById('manual').click=true;
-
if (button1||button2)
-
{
-
alert("button pushed")
-
}
-
else
-
{
-
var q = new Query();
-
if (q.file!=null)
-
{
-
if (q.url!=null)
-
{
-
var file=q.file;
-
var url = q.url;
-
var link="a url";
-
window.opener.location=link;
-
}
-
-
}
-
}
-
}
if i push the button it says the button pushed and if i close the window it says button pushed, so its obviously not working.
any ideas?
cheers
Boyindie
acoder 16,027
Recognized Expert Moderator MVP
Threads merged. If your thread was moved, there was no need to post again.
You can't really detect window close, but if you are going to base it on the button being pressed, set the variable when you click the button (onclick) and then test for it. At the moment, you're always setting it to true.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Brian Vallelunga |
last post by:
I'm working on an asp.net site and am trying to implement a popup help
window. I want the window to close when the user advances to the next page
in our application. The thing is, I'm doing this on a component basis and I
don't have access to the body tag from within my help component, so I can't
add the onunload tag. Is there some other way of achieving what I want? Can
I add an eventhandler to the body tag through javascript?
Thanks,
...
|
by: Andoni |
last post by:
Hi,
I am only writing for IE 5.5+ so no need for compatibility at all ;-)
I am trying to get my users to logoff which they finish on a particular
page. This is no problem (or should be no problem) as I can just put a
location.replace('http://www.mysite.com/html/logoff.jsp'); into the onUnload
event of the page they always finish on. This should fire when they click
the X in the corner (my app. is in a popup window) instead of hitting...
|
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...
|
by: Viktor Popov |
last post by:
Hi,
Iwould like to do that. Is it possible because I can't do it?
in test.aspx file:
<body onunload="signout()">
in test aspx.cs
:
void private signout()
{
HttpContext.Current.Cache.Remove(Session.ToString());
|
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...
| |
by: Angel |
last post by:
I am trying to capture when the user clicks the X button on the ie window. I
have used the onunload for the window event, but there is a problem. I put
javascript code for this event and when the form performs a postback on the
page, the onunload event gets triggered eventhough I am still on the same
page and the user did not click the 'X' button. In other words, the onunload
event is triggered when you are performing a postback to the...
|
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.
|
by: tgh003 |
last post by:
I have been at this for hours now. Pulling my hair out.
I have a standard php page that has an onunload event on it. The
onunload event sends a xmlhttprequest that triggers a database update,
for simplicity lets say it updates a table:
UPDATE testtable SET testfield = '".$_GET."' where id = 1
This works just fine.
Then the next page you navigate to is supposed to call the testfield
|
by: Tim Arview |
last post by:
Hi,
I'm trying to create an exit popup that doesn't require anything added
to the body tag. In other words, I don't want to say <body
onunload="foo">. I just want to have window.onunload="foo" in the
<scripttag.
However, when I do that, it launches foo as soon as the page loads and
does NOT launch when the page is unloaded.
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |