Google Answers Logo
View Question
 
Q: Script for simultaneous redirection and download on IIS 5.0 ( No Answer,   3 Comments )
Question  
Subject: Script for simultaneous redirection and download on IIS 5.0
Category: Computers > Programming
Asked by: londonplayer-ga
List Price: $10.00
Posted: 08 Nov 2005 14:18 PST
Expires: 08 Dec 2005 14:18 PST
Question ID: 590707
When a user clicks a "download now" button on my website I want to
redirect them to another webpage saying the download has begun and at
the same start the download of the EXE. Currently, I am using the
following code to do this but this fails to work consistently on IE
and Firefox. On some occassions the EXE download will not commence
although the redirect will always work. I need to get this to work on
IE 5.5 and above as well as the current version of Firefox. Here is my
current code:

<html>
<body>

<img src="images/header/header_left.jpg" width="396" height="100" />
	<a href="javascript:download()"><img
src="images/header/header_download.gif" width="370" height="100"
border="0" /></a>


	<div id="links">		
		<iframe id="frameDummy" src="" width="0" height="0" frameborder="0"
scrolling="no" style="position:relative;">
		content-holder
		</iframe>
		<iframe id="frameDownload" src="" width="0" height="0"
frameborder="0" scrolling="no" style="position:relative;">
		content-holder
		</iframe>
	</div>




<SCRIPT LANGUAGE=javascript>
	<!--

	
	function download(){	
		window.document.getElementById("frameDummy").src="CaptureClicks.asp";	
		window.document.getElementById("frameDownload").src='http://www.mysite.com/Download.EXE';
		window.document.location.href='ThankYouForDownlaoding.asp';
	}
	//-->
</SCRIPT>
</body>
</html>
Answer  
There is no answer at this time.

Comments  
Subject: Re: Script for simultaneous redirection and download on IIS 5.0
From: zorro_paris-ga on 09 Nov 2005 08:48 PST
 
hi

why don't you use a free component like aspSmartUpload
(http://www.aspsmart.com/aspSmartUpload/) which works very well ? it
will permit you to make easier code :

1- when the users clicks, he's redirect to eg: download.asp?file=Download.EXE
2- this page contains the code from CaptureClicks.asp (stats), then
send the file to the guy, and then redirects him to
'ThankYouForDownlaoding.asp'; all in one page.

another way would be to send the file then redirect him to
'ThankYouForDownlaoding.asp' which contain the code for stats.

i use this component on many websites ant it always worked like a charm

last note : be careful on security with downloading files : avoid
special chars in the filenames to prevent from downloading a system
file : ../../../../windows/win.ini or an asp source file from your
website !! ../download.asp

it could be dangerous

hope this helps

Jul.
Subject: Re: Script for simultaneous redirection and download on IIS 5.0
From: londonplayer-ga on 09 Nov 2005 10:00 PST
 
Hi Jul,

Thanks for your post. We are unable to use the aspSmartUpload as I
only have ftp access to our web server and thus cannot register and
COM DLL. It is a shared commercial web server.

With regards to your other point of sending the file to the user then
re-directing the user to another page, this is what I am doing.
However it has intermittent problems on IE and FF.  See the code
snippet that I provided.

If you have the java script that works, i.e. by starting the download
then re-directing the user to another page, please send it to me. I?ll
can test is on different versions of IE and firefox.

Thanks.
Subject: Re: Script for simultaneous redirection and download on IIS 5.0
From: zorro_paris-ga on 16 Nov 2005 06:45 PST
 
hi ;)

sorry , i didn't know for the dll :(

you can try that, but it's still not 100% sure : 

last line of JS code : 
setTimeout("window.document.location.href='ThankYouForDownloading.asp';",5000);

this will make the page change after 5 seconds. It should be enough
for the download to start...

just a little hack...

hope this helps...

Jul.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy