Results 1 to 6 of 6

Thread: Sorry ASP stuff but need help really badly

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Hi guys,
    Sorry for posting this here but I need help really badly and am really stuck

    I 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
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196
    A couple of things:

    That first part of code looks like javascript, which is a client-side script isn't it? not server side?

    Then you want to use the Request.Querystring on the client-side - this is normally done on server side asp isn't it? Just seems to me like you have the terms round the wrong way (though i could be mistaken on what can be done where).

    additionally, normally you use the following syntax:

    Code:
    Request.QueryString("paramname")
    i've never seen the querystring being used without a parameter, maybe thats the prob...

    ?


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Thanks a lot for the answer. Here's my code so far, I'm still a little bit lost. I changed the language to javascript running on the server. However it won't see window as an object. Do you have any ideas why. Thanks a million. I really appreciate the help
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
    <script language=JScript runat=server>
    function myopen(url,name,parms) {
        var handle = window.open(url,name,parms);
        if (!handle.opener) handle.opener = self;
        return handle;
    }
    </script>
    
    
    <%
    
    myString = Request.Querystring;
    Response.write("<a href= '#' onclick = window.open('http://200.1.20.2" + myString(1) + "','javascript_1')>" + 1 +"</a>");
    Response.Write("<BR>");
    Response.write("<a href= '#' onclick = window.open('http://200.1.20.2" + myString(2) + "','javascript_2')>" + 2 +"</a>");
    Response.Write("<BR>");        
    Response.write(myopen("http://200.1.20.2" + myString(1) + "','javascript_1')"));
    
    %> 
    <html>
    <head>
    
    	<title>Untitled</title>
    
    </head>
    <body>
    
    </body>
    </html>
    [Edited by kanejone on 11-02-2000 at 10:48 AM]

  4. #4
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196
    Off the top of my head the only thing that looks suspicious is the request.querystring because i normally use a parameter after it. Are you passing an actual variable name to the server? if so it should be: request.querystring("varname")

    My javascript knowledge is only in its fledgling stage too.

    i seriously recommend the following site though - it's helped me alot with servlets / asp / javascript so far:

    http://www.wdvl.com

    web developers virtual library...

    sorry i can't be of more help...

    oh hang on - one thing i just thought of, i don't think that javascript should be run at the server - because it doesn't make sense to try to open a window at the server - what you want is the window to pop open to the user who is browsing right? in that case the javascript needs to be executed at the client side. Try changing the script so that it doesn't execute the javascript at the server (so it will execute at the client (browser).

    this is what i would change as an initial guess to your code (just a few things shifted and no more jscript at server).

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
    <script language=JScript>
    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("url")
    Response.write("<a href= '#' onclick = window.open('http://200.1.20.2" & myString & "','javascript_2')>" & 2 & "</a>")
    Response.Write("<BR>")
    Response.write("myopen(http://200.1.20.2" & myString & "','javascript_1')")
    
    %> 
    
    
    </body>
    </html>

    on the asp part <% this is asp %> you don'tneed semicolons to end the lines.

    note - the above code is pretty butchered around - i'm sure it doesn't do what you wanted - but it *will* do something and it runs on my computer -so yeah...have a look at it and it might help you get what you want happening...

    remember that request.querystring is not one string, its a collection of strings or something like that

    gotta go - bed calls...

  5. #5

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

    Wink Cheers

    Thanks a million for the help, I really appreciate it

  6. #6

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

    Wink Figured it out. Thanks a lot for the help

    Thanks for all the help funkyd77

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
    <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("<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>

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