onunload difference in handling IE and Firefox?

  • Thread starter Peter Reinhardt
  • Start date
P

Peter Reinhardt

HI,
there must be a difference in handling the window.onunload-Event for the two
webbrowsers.

I have a window, that shows the uptodate-state of the logged in members.
The state (is active / is not active) ist read out of a mysql-database.
I want to update the database when a member leaves, so his state would be
"is not active".
This update is driven through a javascript call for a file.

So now there is a nice situation:
- IE does everything right. It does not kick the member out of the active
list, when updating, but it kicks a member, when the window is closed.

- Firefox kicks a member, when the window is both updated and closed.

Can anyone help me in this subject? I tried to find a solution on the
Internet, but I wasn't successful...

regards,
Peter
 
V

VK

Peter said:
HI,
there must be a difference in handling the window.onunload-Event for the two
webbrowsers.

I have a window, that shows the uptodate-state of the logged in members.
The state (is active / is not active) ist read out of a mysql-database.
I want to update the database when a member leaves, so his state would be
"is not active".
This update is driven through a javascript call for a file.

So now there is a nice situation:
- IE does everything right. It does not kick the member out of the active
list, when updating, but it kicks a member, when the window is closed.

- Firefox kicks a member, when the window is both updated and closed.

Can anyone help me in this subject? I tried to find a solution on the
Internet, but I wasn't successful...

Use "onbeforeunload" instead in both cases.
 
P

Peter Reinhardt

Use "onbeforeunload" instead in both cases.
here's a part of my php-script:
-------------------------------------------------------------------
echo "<script type='text/javascript'>
<!--
window.onunload = zuper;
function zuper(){
location.href='show.php?closeboard=1&closefile=$fileId';
//-->
</script>";

if($_GET['closeboard']==1){

$fileId = $_GET['closefile'];
$deleteQ = " DELETE FROM codereview_editors "
." WHERE Nachname = \"$nachname\""
." AND Vorname = \"$vorname\""
." AND FileID = ".$fileId;
$db->query($deleteQ);
}
 
V

VK

Peter said:
Use "onbeforeunload" instead in both cases.
here's a part of my php-script:
-------------------------------------------------------------------
echo "<script type='text/javascript'>
<!--
window.onunload = zuper;
function zuper(){
location.href='show.php?closeboard=1&closefile=$fileId';
//-->
</script>";

if($_GET['closeboard']==1){

$fileId = $_GET['closefile'];
$deleteQ = " DELETE FROM codereview_editors "
." WHERE Nachname = \"$nachname\""
." AND Vorname = \"$vorname\""
." AND FileID = ".$fileId;
$db->query($deleteQ);

Could you give the actual HTML dump instead? If you don't have a PHP
converter handy on your server then simply open the page of question in
any browser and View > Page Source then Copy'n'Past

Will be much easier to aswer after the above is done, really.
 
R

Randy Webb

Peter Reinhardt said the following on 2/3/2006 5:02 AM:
HI,
there must be a difference in handling the window.onunload-Event for the two
webbrowsers.

Would those "two webbrowsers" you are referring to be Konqueror and
ICEBrowser? Do not fall into the mistake of thinking there are only two.
I know of at least 150 and there are more.
I have a window, that shows the uptodate-state of the logged in members.
The state (is active / is not active) ist read out of a mysql-database.
I want to update the database when a member leaves, so his state would be
"is not active".
This update is driven through a javascript call for a file.

So now there is a nice situation:
- IE does everything right.

"right" or as you want? There is a difference.
It does not kick the member out of the active list, when updating,
but it kicks a member, when the window is closed.

- Firefox kicks a member, when the window is both updated

What are you calling "updating"? How you update will make a difference.
 
T

Thomas 'PointedEars' Lahn

Peter said:
Use "onbeforeunload" instead in both cases.
^^^^^^
here's a part of my php-script:
-------------------------------------------------------------------
echo "<script type='text/javascript'>
<!-- ^^^^
window.onunload = zuper; ^^^^^^^^
function zuper(){
location.href='show.php?closeboard=1&closefile=$fileId';
//--> ^^^^^
</script>";

if($_GET['closeboard']==1){

$fileId = $_GET['closefile'];
$deleteQ = " DELETE FROM codereview_editors "
." WHERE Nachname = \"$nachname\""
." AND Vorname = \"$vorname\""
." AND FileID = ".$fileId;
$db->query($deleteQ);
}

See above. Should be

<script type="text/javascript">
window.onbeforeunload = function()
{
location.href="show.php?closeboard=1&closefile=<?php echo $fileId; ?>";
}
</script>
<?php
// if this refers to a checkbox, isset($_GET['closeboard']) is better
if ($_GET['closeboard'] == 1)
{
$fileId = $_GET['closefile'];

// HereDoc syntax is supported since PHP4
$deleteQ = <<<SQL
DELETE FROM codereview_editors
WHERE Nachname="$nachname"
AND Vorname="$vorname"
AND FileID="$fileId"
SQL;

$db->query($deleteQ);
}
?>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top