Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert external js to script within an asp page

Status
Not open for further replies.

kurtmo5

Programmer
Jul 16, 2004
18
US
Here is the code I need to replace but using Response.Write commands. It works fine as an external file but when entered into the ASP then it gives me errors. What do I need to do? Thanks.

Sub openDocument(file)
Set oShell = CreateObject("Wscript.Shell")
oShell.Run chr(34) & file & chr(34)
End Sub
 
Try:
Code:
    Sub openDocument(file)
        Set oShell = Server.CreateObject("Wscript.Shell")
        oShell.Run chr(34) & file & chr(34)
    End Sub

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Nope, that didn't work. Maybe I misstated my question. I need to use this exact code(if possible). The only problem is when I place the Response.Write(""); and include the script inside these the error occurs.
 
So what is the actual code you are trying to run?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Response.Write("<script language=\"vbscript\">");
Response.Write("<br>sub openDocument(file)</br>");
Response.Write("<br>set oShell = CreateObject(\"Wscript.Shell\")</br>");
Response.Write("<br>oShell.Run chr(34) & file & chr(34)</br>");
Response.Write("End Sub");
Response.Write("</script>");
 
So you are dynamically creating a seperate page?


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
yes it reads the extension and then opens the appropriate application with the filename being opened
 
So if you change CreateObject to Server.CreateObject and then load the newly created page, what happens?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I was still getting the error message. I just figured out my problem. When inserting the script within the page I needed to add the <% %> tags around the script and this seemed to make the script functional. When using the external.js there was no need for them. Would this make sense?
 
Yes.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Hello kurtmo5,

My understanding of what you need to do is to make script on the client-side, the main is errors of translation.
\" should be read ""
; separator should be spared
plus some other formatting need-to-know detail.

Hence, the translation be"
Code:
<%
Response.Write("<script language=""vbscript"">")
Response.Write(unescape(vbcrlf & "sub openDocument(file)"))
Response.Write(unescape(vbcrlf & "set oShell = CreateObject(""Wscript.Shell"")" & vbcrlf))
Response.Write(unescape("oShell.Run chr(34) & file & chr(34)" & vbcrlf ))
Response.Write(unescape("End Sub"&vbcrlf))
Response.Write("</script>")
%>
regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top