By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

onunload difference in handling IE and Firefox?

P: n/a
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
Feb 3 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
VK

Peter Reinhardt wrote:
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. regards,
Peter


Feb 3 '06 #2

P: n/a
> 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=$fi leId';
//-->
</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);
}
-------------------------------------------------------------------
Where is my mistake?
Feb 3 '06 #3

P: n/a
VK

Peter Reinhardt wrote:
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=$fi leId';
//-->
</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
}
-------------------------------------------------------------------
Where is my mistake?


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

Feb 3 '06 #4

P: n/a
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 3 '06 #5

P: n/a
Peter Reinhardt wrote:
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=$fi leId';
//--> ^^^^^ </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);
}
-------------------------------------------------------------------
Where is my mistake?


See above. Should be

<script type="text/javascript">
window.onbeforeunload = function()
{
location.href="show.php?closeboard=1&closefile=<?p hp 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
Feb 3 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.