I want to display a pop-up page (message) then exit that page after three seconds. How would I go about this?
Is this similar to a META refresh tag?
Printable View
I want to display a pop-up page (message) then exit that page after three seconds. How would I go about this?
Is this similar to a META refresh tag?
You can use java script to pop up a page and then close it after 3 seconds, just google for it (I don't know java script very well).
Though I really wish you wouldn't do this. I hate this stuff and my browser won't even open the initial pop-up :D
kasracer
Not neccessarily looking for a pop-up window. I just need to display some status info to the user while time passes to keep them from pressing on the link again until I can connect to the FTP site (or give the browser time to put up its message).
I am doing this from a perl script. You know of a better way. I forgot about the pop-ups. I do not want that either, I block those too. So pop-up isn't what I really want.
Ok, then how do you make a displayed HTML page shut down (exit) after three seconds?
Actually, here is the page I want to disappear after three seconds
Code:Content-type: text/html
<html>
<head>
<title>File Download</title>
</head>
<style type="text/css">
<!--
A:visited {text-decoration: none;; color: #000000}
A:link {text-decoration: none;; color: #000000}
A:active {text-decoration: none;; color: #000000}
A:hover {text-decoration: underline; color:red;}
td { font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
tt { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13pt; font-weight: bold}
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<center>
<table width="600" height="50" border="0" cellspacing="0" cellpadding="3" align="center">
<tr>
<td><tt>Contacting Download Site Please Wait...</tt>
</tr>
</table>
<script>
window.location = "http://68.195.10.97/downloads/Test.zip"
</script>
Won't that opage automatically change to Test.zip when the file is downloaded?
what you could so is this:
Place all the code you want hidden in a span called mySpan
ie. <span id="mySpan">My HTML code which will be hidden</span>
Then run this code onLoad:
That will delete the text in the span after 3 secs.Code:MYTimer = setTimeout("document.getElementById('mySpan').innerHTML=''",3000)
Acidic is probably right. Once the browser attempts to download the file, JavaScript might not be executed anymore. On the other hand, if it is executed too early (e.g. before the browser has contacted the server) the file might not get downloaded at all.
Just a question though. So many download pages don't have this and work fine. Why is this such a problem for you?
To build on Ac's code and completly remove the span, not only emtying it:
Code:setTimeout("var e = document.getElementById('mySpan'); e.parentNode.removeChild(e)",3000);
I know CB, I could also have used outerHTML instead of innerHTML to remove it.
Yes, why exactly is this a problem?
CornedBee
Well, this does not work for me because, When the user clicks on the link to download files. the browser attempts to contact the FTP site and this looks like nothing is happening. So the user clicks on it again.
Now as far as download counts, this throws the counts off because the second or third download is usually cancelled. I need an acurate count to coincide with the actual bandwidth my ISP is charging me for.
So to put up any kind of message that something is happening will deter clicking on the link again.
No, you couldn't safely use outerHTML, it's only implemented by IE.
I think in another thread it's already been suggested. Make the link point to a download page which says "the download will begin shortly, please stand by". Then forward to the ftp url.
thx CB.
randem, I would do this instead in that case.
make a link to the file, like you have done before. then make a message pop up (not in a new window) telling them to hold on for a minute or two:
Code:<script type="text/javascript">
function doIt() {
document.getElementById('mySpan').innerHTML = "<font color='red'>Please wait a minute for the download to work</font>"
location.href = "ftp://123.123.123/1223.zip" /*Obviously this line needs changing */
}
</script>
<span id="mySpan"></span>
<button onClick="doIt()">Get the file</button>
Acidic
I will try that. Now if the user does not have Java enabled it will need a <noscript> section that just downloads the file with no message, yes?
I have seen this somewhere, true.