Problems with javascript in asp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NewUser

    Problems with javascript in asp

    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.CreateOb ject("AspSmartU pLoad.SmartUpLo ad")
    Call objFile.Downloa dFile("\\Myserv er\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=Javasc ript src="../MyScripts/test.js"
    type=text/javascript></SCRIPT>
    <script language="javas cript">
    var fileurl;
    var strrtn;
    var outputfile;

    strrtn = chop();

    </script>
    <% elseif status = "B" then %>
    <script language="javas cript">
    alert("B");
    </script>
    <% End if %>

    <%

    dim objFile
    Set objFile = Server.CreateOb ject("AspSmartU pLoad.SmartUpLo ad")
    Call objFile.Downloa dFile("\\Myserv er\filename" , "video/x-ms-wmv",
    "myfile")
    set objFile = nothing

    %>

  • McKirahan

    #2
    Re: Problems with javascript in asp

    "NewUser" <rchatrathi@hot mail.com> wrote in message
    news:1116619220 .970559.310400@ f14g2000cwb.goo glegroups.com.. .[color=blue]
    > 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.CreateOb ject("AspSmartU pLoad.SmartUpLo ad")
    > Call objFile.Downloa dFile("\\Myserv er\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=Javasc ript src="../MyScripts/test.js"
    > type=text/javascript></SCRIPT>
    > <script language="javas cript">
    > var fileurl;
    > var strrtn;
    > var outputfile;
    >
    > strrtn = chop();
    >
    > </script>
    > <% elseif status = "B" then %>
    > <script language="javas cript">
    > alert("B");
    > </script>
    > <% End if %>
    >
    > <%
    >
    > dim objFile
    > Set objFile = Server.CreateOb ject("AspSmartU pLoad.SmartUpLo ad")
    > Call objFile.Downloa dFile("\\Myserv er\filename" , "video/x-ms-wmv",
    > "myfile")
    > set objFile = nothing
    >
    > %>
    >[/color]

    Try removing the word "Call " from "Call objFile.Downloa dFile()"?


    Comment

    • Grant Wagner

      #3
      Re: Problems with javascript in asp

      "NewUser" <rchatrathi@hot mail.com> wrote in message
      news:1116619220 .970559.310400@ f14g2000cwb.goo glegroups.com.. .[color=blue]
      >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.CreateOb ject("AspSmartU pLoad.SmartUpLo ad")
      > Call objFile.Downloa dFile("\\Myserv er\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=Javasc ript src="../MyScripts/test.js"
      > type=text/javascript></SCRIPT>
      > <script language="javas cript">
      > var fileurl;
      > var strrtn;
      > var outputfile;
      >
      > strrtn = chop();
      >
      > </script>
      > <% elseif status = "B" then %>
      > <script language="javas cript">
      > alert("B");
      > </script>
      > <% End if %>
      >
      > <%
      >
      > dim objFile
      > Set objFile = Server.CreateOb ject("AspSmartU pLoad.SmartUpLo ad")
      > Call objFile.Downloa dFile("\\Myserv er\filename" , "video/x-ms-wmv",
      > "myfile")
      > set objFile = nothing
      >
      > %>[/color]

      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.Downloa dFile() isn't executing on the client?

      When you do Call objFile.Downloa dFile(), 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 = 'pageContaining DownloadFile.as p';
      </script>

      -- pageContainingD ownloadFile.asp

      <%

      dim objFile
      Set objFile = Server.CreateOb ject("AspSmartU pLoad.SmartUpLo ad")
      Call objFile.Downloa dFile("\\Myserv er\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 <gwagner@agrico reunited.com>
      comp.lang.javas cript FAQ - http://jibbering.com/faq


      Comment

      Working...