"NewUser" <rc********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have to call a js function from asp. If the last portion which is
the following code is omitted
<%
dim objFile
Set objFile = Server.CreateObject("AspSmartUpLoad.SmartUpLoad")
Call objFile.DownloadFile("\\Myserver\filename" , "video/x-ms-wmv",
"myfile")
set objFile = nothing
%>
from my asp file, then the javascript works fine. But if the above
code is included in my asp page, the javascript code is not executed.
I have to call the js function with in my asp page depending on the
status. Any ideas are appreciated.
This is the code I have:
<% if status = "A" then %>
<SCRIPT language=Javascript src="../MyScripts/test.js"
type=text/javascript></SCRIPT>
<script language="javascript">
var fileurl;
var strrtn;
var outputfile;
strrtn = chop();
</script>
<% elseif status = "B" then %>
<script language="javascript">
alert("B");
</script>
<% End if %>
<%
dim objFile
Set objFile = Server.CreateObject("AspSmartUpLoad.SmartUpLoad")
Call objFile.DownloadFile("\\Myserver\filename" , "video/x-ms-wmv",
"myfile")
set objFile = nothing
%>
If I understand correctly, you're wondering why client-side JavaScript
that is being thrown away and never reaches the client when you specify
Call objFile.DownloadFile() isn't executing on the client?
When you do Call objFile.DownloadFile(), the server tosses away all the
previous output and headers, specifies (in this case) Content-Type:
video/x-ms-wmv; and sends the file.
You can't have your cake and eat it too. You can't send Content-Type:
text/html; containing client-side JavaScript, then send Content-Type:
video/x-ms-wmv; from a single GET. What you _could_ do is rely on
client-side JavaScript to execute and then redirect you to the ASP file
containing your DownloadFile() method call:
-- page1.asp
<script type="text/javascript">
alert('Hi there');
location.href = 'pageContainingDownloadFile.asp';
</script>
-- pageContainingDownloadFile.asp
<%
dim objFile
Set objFile = Server.CreateObject("AspSmartUpLoad.SmartUpLoad")
Call objFile.DownloadFile("\\Myserver\filename" , "video/x-ms-wmv",
"myfile")
set objFile = nothing
%>
But this places a dependancy on client-side JavaScript that I would
probably find unacceptable on the public Internet.
--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq