Click to See Complete Forum and Search --> : Passing a Jscript function in ASP
kanejone
Nov 2nd, 2000, 09:05 AM
Ì have the following function:
function myopen(url,name,parms) {
var handle = window.open(url,name,parms);
if (!handle.opener) handle.opener = self;
return handle;
}
I want to run this function on from ServerSide Script. I am receiving the names of html files from a querystring and I'm trying to open them when the page loads.
I want to use the the following:
[code]
myString = Request.Querystring;
myopen("myString","NEW WINDOW");
[/code}
Can someone please tell me how to use this client side function so that it runs from the server.
Thanks a lot
Johnny
monte96
Nov 2nd, 2000, 10:17 AM
Where you want to run the client side code, you would need to simply response.write it to the page in script tags but not as a function. So you would do something like this:
myString = Request.Querystring;
'myopen("myString","NEW WINDOW");
Response.Write "<SCRIPT language=javascript>" & vbCrLf
Response.Write "var handle = window.open('myString','NEW WINDOW');" & vbCrLf
Response.Write "if (!handle.opener) handle.opener = self;" & vbCrLf
Response.Write "</SCRIPT>"
The handle variable will not, however be available to your server side script, only the other client side script on your page. (It becomes page scope)
kanejone
Nov 2nd, 2000, 10:42 AM
Thanks a million.
Hers's the working code, if anyone else needs it.
Thanks again.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@Language=Javascript%>
<script language="javascript">
function myopen(url,name,parms) {
var handle = window.open(url,name,parms);
if (!handle.opener) handle.opener = self;
return handle;
}
</script>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<%
myString = Request.Querystring()
Response.write(myString())
Response.write("<SCRIPT language=JavaScript>")
Response.Write("var handle = window.open('http://200.1.20.2" + myString(1) + "','javascript_1');")
Response.Write("var handle = window.open('http://200.1.20.2" + myString(2) + "','javascript_2');")
Response.Write("var handle = window.open('http://200.1.20.2" + myString(1) + "','javascript_3');")
Response.Write("</SCRIPT>")
%>
</body>
</html>
[Edited by kanejone on 11-03-2000 at 05:15 AM]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.