-
Ì have the following function:
Code:
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
-
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)
-
Thanks a million.
Hers's the working code, if anyone else needs it.
Thanks again.
Code:
<!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]