Results 1 to 3 of 3

Thread: Passing a Jscript function in ASP

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Question

    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

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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)

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    monte96_@hotmail.com
    monte96@vbgarage.com


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    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]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width