Php close window after x amount of time

Asked
Active3 hr before
Viewed126 times

6 Answers

closewindow
90%

If You don't need to see what You page displays, instead of using web browser, use some non-interactive tool that fetches websites, like wget or cURL. Both of them should be available as executable windows binaries. This will keep same behaviour for PHP script like normal webbrowser visit, except javascript which, you mentioned, wish to avoid, and will be not executed. Wget or cURL will only fetch content of generated page.,The following code would open the IE browser with the URL mentioned ($url) and in the sleep parameters pass the time upto which you want the window to remain opened (parameter is in seconds)., PHP is a server side script which can't do anything on the browser of the client. But if the server is on the same PC as the client you may take a look at the PHP exec() function and taskkill in windows, however this will close the whole browser instead of just the tab. – HamZa Apr 30 '13 at 19:40 ,I'm running apache, php, mysql on windows 7. I'm using windows task schedule to open a 'cron job' (php script) on my localhost server. In php I would like to close that tab in the window after 30 minutes (to ensure the script has operated). I know how to do it in javascript using setTimeout() and window.close() functions, but I'm avoiding javascript in this code. Is there a way to do it in php? Or if anyone knows how to do it in windows task scheduler, that would be good too.

The following code would open the IE browser with the URL mentioned ($url) and in the sleep parameters pass the time upto which you want the window to remain opened (parameter is in seconds).

//The code starts from here:
$browser = new COM("InternetExplorer.Application");
$handle = $browser - > HWND;
$browser - > Visible = true;
$browser - > Width = 1100;
$browser - > Height = 700;
//$url=your url you want to open
print_r($browser - > Navigate($url));
while ($browser - > Busy) {
   com_message_pump(5000);
}
//The time you think is sufficient to open your web page
sleep(10);
$browser - > Quit();
88%

The Window.close() method closes the current window, or the window on which it was called. , This example shows a method which opens a window and a second one which closes the window; this demonstrates how to use Window.close() to close a window opened by calling window.open(). , Note also that close() has no effect when called on Window objects returned by HTMLIFrameElement.contentWindow. , This method can only be called on windows that were opened by a script using the Window.open() method. If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.

window.close();
load more v
72%

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 :),This is an example of JavaScript automatic popup closing after 3 seconds with countdown,, 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,ok no thats alreayd been stated before. but LOL the header actually did work... thanks im closing this cause u guys all helped a lot thanks again!

<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>

also

<body onload="javascript:settimeout('self.close()',5000);">
load more v
65%

The refresh code can be executed after a certain period of time using the setTimeout() function. This function has a delay parameter which denotes the time after which the function will execute. This value is given in milliseconds. The amount of time in seconds to be delayed in multiplied by 1000 to convert it to milliseconds.,The setTimeout code can be called after the document has finished loading by selecting the document object and using the ready() method on it. This will cause the page to reload after the specified amount of seconds.,A page can be reloaded after a specific number of seconds in jQuery using two approaches.,This code can be called after the document has finished loading by selecting the document object and using the ready() method on it. This will cause the page to reload after the specified amount of seconds.

Syntax:
$(document).ready(function() {
   setTimeout(function() {
      alert('Reloading Page');
      location.reload(true);
   }, 5000);
});
load more v
75%

The given output window will get closed after 3 seconds which can be modified by changing the value in the after (time, callback) method.,Running the above code will display a window that will get closed after 3 seconds.,In order to close a Tkinter application, we generally refer to close the parent window using the destroy() method. To close the Tkinter window automatically after a certain time limit, we have to use the after(time in ms, callback) method by specifying the time and the callback function which needs to be run after a certain time limit.,How do I handle the window close event in Tkinter?

Example

#Import the required Libraries
from tkinter
import *
from tkinter
import ttk

#Create an instance of tkinter frame
win = Tk()

#Set the geometry of tkinter frame
win.geometry("750x270")

#Initialize a Label widget
Label(win, text = "This window will get closed after 3 seconds...",
   font = ('Helvetica 20 bold')).pack(pady = 20)

#Automatically close the window after 3 seconds
win.after(3000, lambda: win.destroy())

win.mainloop()
40%

Javascript Language HTML & CSS Form Java interaction Mobile Varia

<SCRIPT>
   setTimeout("self.close()", 5000) // after 5 seconds
</SCRIPT>

Other "close-window" queries related to "Php close window after x amount of time"