|
-
Feb 28th, 2006, 01:04 PM
#1
Thread Starter
Member
Help me please...
Hi, help me please. I need write to mysql and after this window close. But when window is closing then mysql haven't time to write. (because window is closing)
The closing must waiting while information is writed in mysql database.
(on local host have writing time and all is OK but on Net Or Internet it's bad)
-
Feb 28th, 2006, 01:11 PM
#2
<?="Moderator"?>
Re: Help me please...
What window are you talking about? A window that you have opened or the main browser window?
-
Feb 28th, 2006, 01:22 PM
#3
Fanatic Member
Re: Help me please...
yiiish...
really can't figure out what window you are talking about...
-
Feb 28th, 2006, 04:10 PM
#4
Lively Member
Re: Help me please...
Dobré ráno.
How are you trying to close the page?
I expect you are using a combination of server-side and client-side, so the MySQL should be completed before you get anywhere near the client-side.
Code:
<?
// DO YOUR INSERT/UPDATE/DELETE, WHATEVER UP HERE
// NOW CLOSE THE WINDOW
echo '<script> window.close(); </script>';
?>
Perhaps seeing the code will help.
-
Feb 28th, 2006, 04:20 PM
#5
Thread Starter
Member
Re: Help me please...
I need write to MYSQL with event ONUNLOAD.
I try:
<body onunload=window.open("win.php")>
and in this page (win.php) I have code to write to MYSQL.
But it's problem.
..
..
mysql_db_query('..','..','..');
..
..
?>
<script>window.close()</script>
mysql haven't more time to write
-
Feb 28th, 2006, 05:05 PM
#6
Lively Member
Re: Help me please...
I've experienced that before actually. Instead of writing the javascript below your last delimeter (?>), make sure to echo it, like this:
Code:
echo '<script> window.close(); </script>';
If it still doesn't work, I haven't a clue.
-
Feb 28th, 2006, 05:42 PM
#7
<?="Moderator"?>
Re: Help me please...
Opening a new window might anoy the user, i know it would annoy me. You can do what you want without the users seeing it using ajax.
PHP Code:
<html>
<head>
<script language="javascript">
function createRequestObject()
{
var request_o; //declare the variable to hold the object.
var browser = navigator.appName; //find the browser name
if(browser == "Microsoft Internet Explorer"){
/* Create the object using MSIE's method */
request_o = new ActiveXObject("Microsoft.XMLHTTP");
}else{
/* Create the object using other browser's method */
request_o = new XMLHttpRequest();
}
return request_o; //return the object
}
var http = createRequestObject();
function ClosingWindow()
{
http.open('get', 'win.php');
http.send(null);
}
</script>
</head>
<body onunload="javascript:ClosingWindow();">
<!--// Your page information //-->
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|