| | |
how can i make a window close itself after running the php code
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 279
Reputation:
Solved Threads: 2
i know how to do the link thing that if u click it it closes the window. but im wondering if theres a way to automatically close a window after the php code is done running.
cause i have an inbox and theres a link to delete the message if you click on it it will open up a new windows and run the php script to delete the message then it will say message deleted. im wondering how instead if just saying msg deleted it can close itself(the window) as well? does anyone know how? can i do it with pure php or do i need javascript too? i figured javascript.
because the link ive come up with stuff im working on elsewhere is a javascript link to close the window.
anyone know the javascript to do this? plz helps.?
cause i have an inbox and theres a link to delete the message if you click on it it will open up a new windows and run the php script to delete the message then it will say message deleted. im wondering how instead if just saying msg deleted it can close itself(the window) as well? does anyone know how? can i do it with pure php or do i need javascript too? i figured javascript.
because the link ive come up with stuff im working on elsewhere is a javascript link to close the window.
anyone know the javascript to do this? plz helps.?
0
#2 18 Days Ago
html Syntax (Toggle Plain Text)
<html><head></head><body>This is a popup window,<br> which may not open on any random system thanks to popup blockers<br> on the chance that it does open, I want to close it 5 seconds later <script type='text/javascript'> <!-- settimeout('self.close()',5000); --></script></body></html>
html Syntax (Toggle Plain Text)
<body onload="javascript:settimeout('self.close()',5000);">
Last edited by almostbob; 18 Days Ago at 1:14 am.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Apr 2009
Posts: 279
Reputation:
Solved Threads: 2
-1
#3 18 Days Ago
thanks but if i set it to 5 will it start after the code beofre it is run
that one. cause well i need to have the code before it run before the window closes?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type='text/javascript'> <!-- settimeout('self.close()',5000); --></script>
that one. cause well i need to have the code before it run before the window closes?
Last edited by peter_budo; 17 Days Ago at 7:09 pm. Reason: Correcting code tags
•
•
Join Date: Apr 2009
Posts: 279
Reputation:
Solved Threads: 2
0
#4 18 Days Ago
•
•
•
•
alsohtml Syntax (Toggle Plain Text)
<html><head></head><body>This is a popup window,<br> which may not open on any random system thanks to popup blockers<br> on the chance that it does open, I want to close it 5 seconds later <script type='text/javascript'> <!-- settimeout('self.close()',5000); --></script></body></html>html Syntax (Toggle Plain Text)
<body onload="javascript:settimeout('self.close()',5000);">
•
•
Join Date: Oct 2009
Posts: 99
Reputation:
Solved Threads: 18
0
#5 18 Days Ago
Since you're running PHP code, the JS wil only be executed after the PHP code is run. So you can run it with or without a timeout. Simply adding the following code anywhere (valid) in the HTML page is enough,
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type='text/javascript'> self.close(); </script>
•
•
Join Date: Oct 2009
Posts: 99
Reputation:
Solved Threads: 18
0
#8 18 Days Ago
Just a note.
Ideally though, you shouldn't be opening a popup to delete whatever it is you are deleting. You should just be redirecting to the delete page, and the delete page would redirect back to the index page.
Something like this
This way there are no mysterious popups appearing for the user. Although it may seem fast for you (since you are running it locally). On a slow connection, the user would only see a blank popup opening and closing. He might get worried
Anyway, just some thoughts. Close this thread if you are done with it please.
Ideally though, you shouldn't be opening a popup to delete whatever it is you are deleting. You should just be redirecting to the delete page, and the delete page would redirect back to the index page.
Something like this
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
//index.php <a onclick="return confirm('Are you sure?')" href="delete.php?id=4">Delete</a> //delete.php //Code to delete //Redirect back to index.php
This way there are no mysterious popups appearing for the user. Although it may seem fast for you (since you are running it locally). On a slow connection, the user would only see a blank popup opening and closing. He might get worried

Anyway, just some thoughts. Close this thread if you are done with it please.
•
•
Join Date: Apr 2009
Posts: 279
Reputation:
Solved Threads: 2
-1
#9 18 Days Ago
•
•
•
•
Just a note.
Ideally though, you shouldn't be opening a popup to delete whatever it is you are deleting. You should just be redirecting to the delete page, and the delete page would redirect back to the index page.
Something like this
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
//index.php <a onclick="return confirm('Are you sure?')" href="delete.php?id=4">Delete</a> //delete.php //Code to delete //Redirect back to index.php
This way there are no mysterious popups appearing for the user. Although it may seem fast for you (since you are running it locally). On a slow connection, the user would only see a blank popup opening and closing. He might get worried
Anyway, just some thoughts. Close this thread if you are done with it please.
but there is two different ways to delete messages, the first way is the open window which for me is always a tab. and then it deletes it and thats on the inbox page which target="_blank" is necassary because its easier to delete multiple messages all on one page. and then the other way which i might have to do the redirecting although am currently using the same thing which is the open page then auto close this delete button is on the message page itself. which its kind of odd i press delete and it deletes(maybe someone would press delete 5 times and not know it was deleted) so i guess ill have to redirect but i cant use target blank so what do i do. i submit the delete form and it brings the user to a page without a popup to delete. it brings the user to the delete page but it has to run through if(isset($_POST[delete])){do the php delete actions in for deleting the message from the mysql database t
but then what? i dont understand the redirecting i would use here
oh and i dont run things locally. i dont understand winamp
Last edited by SKANK!!!!!; 18 Days Ago at 2:29 am.
•
•
Join Date: Oct 2009
Posts: 99
Reputation:
Solved Threads: 18
0
#10 18 Days Ago
You'd have this kind of setup
First the Index page
Now the delete page
This way there are no new windows or popups.
If you want users to be able to delete multiple messages at once, you'd have to modify the code so that users can select which messages are to be deleted. You can use an array of checkboxes for this and modify the delete code to work with an array. But then you'd have to use a FORM element to submit. That's another topic, some info can be found here
First the Index page
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
//fake display structure <ul> <li>Item 1 - <a onclick="return confirm('Are you sure?')" href="delete.php?id=1">Delete</a></li> <li>Item 2 - <a onclick="return confirm('Are you sure?')" href="delete.php?id=2">Delete</a></li> <li>Item 3 - <a onclick="return confirm('Are you sure?')" href="delete.php?id=3">Delete</a></li> <li>Item 4 - <a onclick="return confirm('Are you sure?')" href="delete.php?id=4">Delete</a></li> </ul>
Now the delete page
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<?php $id = isset($_GET['id']) ? intval($id) : 0; if ($id) { //just some validations //do delete commands header("Location: index.php"); //It's important that you haven't output anything upto this point } ?>
This way there are no new windows or popups.
If you want users to be able to delete multiple messages at once, you'd have to modify the code so that users can select which messages are to be deleted. You can use an array of checkboxes for this and modify the delete code to work with an array. But then you'd have to use a FORM element to submit. That's another topic, some info can be found here
![]() |
Similar Threads
- window.close() problems (JavaScript / DHTML / AJAX)
- xampp not running php as well as html files (PHP)
- Delay Window Close (JavaScript / DHTML / AJAX)
- site will not display php, only the code contents (PHP)
- Problem closing Browser with Window.Close (ASP.NET)
- Using HTML tags in PHP code (PHP)
- How to close IE without a user dialog box? (JavaScript / DHTML / AJAX)
- How to test PHP code in offline in Linux + Apache 2 (PHP)
- My embedded php code won't execute (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Warning Message on Browser Close
- Next Thread: Get, show PDF, JPG, Video
| Thread Tools | Search this Thread |
adobe air ajax array automatically basic beginner body broken c# cart cheap checkbox class cms column createrange() curl data database display dom downloader dropdownlist duplicates email errorlog file files firefox flash form forms functions gentoo gwt highlightedword html iframe image images include javascript jquery jsp libcurl link logfiles login mail malfunction menu minimalizes multiple multipletables mysql navigation network news nodes oop open outofmemmory paypal pdf php post provider quality query ruby script search security select shopping simple sms smtp soap sockets source spam sql static support! tables text textbox traffic tutorial unicode upload validation video web window youtube zend zeroday







