Jump to content

closing a window after script has finished


justAnoob

Recommended Posts

Am I able to call a javascript function before the script is ran, and then after the script is done, run another js function?

 

ex:

<?php

js function          before running script

script stuff here

js function          after script is finished

?>

 

If this gets to off topic, I have this posted in the js section also.  I just wanted to give gergy008 a response. Sorry for the double post. Let me know if I have to close this one down.

Link to comment
Share on other sites

Yes this is the wrong section, as this is a javascript problem, but you are probably looking for something along the lines of

window.close();

 

look it up on google. Although, I think if you try to close the main browsing window, it will throw a message. Why do you want to close the browser anyways?

Link to comment
Share on other sites

i'm not looking to close the browser or the main page the user is on. Here it is again.

the user goes to an upload page, they hit submit to upload, a popup window displays letting them know that something is happening, when the script is done uploading they are taken to a new page and the popup window is to be closed. it is just the popup window that I want to open before the script and then close after the script. I have searched everywhere on google and cannot find a way to do this. And ok, i'll continue this is js section

Link to comment
Share on other sites

You don't need to have a popup. Most browser block them anyway...

 

The JavaScript:

function upload(formdiv, messagediv){
var formID = document.getElementById(formdiv);
var messID = document.getElementById(messagediv);
formID.style.display = 'none';
messID.style.display = 'block';
}

 

The HTML:

<div id="form">
<form action="post_somewhere.php" method="post" enctype="multipart/form-data">
	<p><label for="file">File:</label> <input type="file" name="somename" id="file" /></p>
	<p><input type="submit" value="Submit!" onclick="upload('form', 'message');" /></p>
</form>
</div>
<div id="message" style="display:none;">
<h1>Uploading...</h1>
<p>
	Please wait, your file is uploading. Do NOT refresh the page, the page will refresh on it's own.
	Larger files will take longer to upload, please be patient.
</p>
<p>
	Thanks!
</p>
</div>

Link to comment
Share on other sites

I need to call the function inside of the upload script file, and the javascript needs to be ran before the php script so the message is displayed for the user while they are waiting. So is there something I could do inside of the PHP upload script to display the wait message?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.