Using socket code / no browser to issue a Javascript event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan DeBardeleben

    Using socket code / no browser to issue a Javascript event

    This may seem wierd, and I know someone asked this question before but
    was told they were doing it the hard way. Unlike them, I do not have
    shell access to the machine where this javascript runs.

    I need to run the 'submit' method on a Javascript on a page - but I
    need to do it without a browser. I can handle all the socket code,
    that's not the issue, the issue is what command I need to send. I
    should be able to hit the page and issue it's functionality just like
    I could with a wget or by pasting a CGI with its actions into a
    browser window.

    Ideas?

    Here's the snippet of the method I need to call - nothing special at
    all.

    <form name="click" action="mysite/cgi-bin/my.cgi" method="POST">
    <input type="hidden" name="ses" value="36602107 9">
    <input type="hidden" name="id" value="somevalu e">
    <script language="JavaS cript">
    <!--
    document.write( '<a href="javascrip t:document.clic k.submit()"><im g
    src="/images/img.gif" width=290 height=73 alt="alt text"
    border=0></a>');
    //-->
    </script>

    <noscript>
    <input type="submit" value="Submit">
    </noscript>
    </form>

    The browser, if I use that lists the link as:
    javascript:docu ment.click.subm it().
    I need to call that method remotely.
    I know all the above values - that's not the issue - I just need to
    find a way to make it execute the submit() function where I can pass
    in the variables. I know in CGI I could do things like
    .....cgi&value= "foo"&value2="b ar", etc.

    Thanks in advance.
  • Philip Ronan

    #2
    Re: Using socket code / no browser to issue a Javascript event

    Nathan DeBardeleben wrote:
    [color=blue]
    > This may seem wierd, and I know someone asked this question before but
    > was told they were doing it the hard way. Unlike them, I do not have
    > shell access to the machine where this javascript runs.
    >
    > I need to run the 'submit' method on a Javascript on a page - but I
    > need to do it without a browser.[/color]

    Yes, that sounds weird.
    [color=blue]
    > I can handle all the socket code,
    > that's not the issue, the issue is what command I need to send.[/color]

    You lost me there. You want to run Javascript in a browser that doesn't
    exist, and you want to know what command to send it?

    Do you mean you want to simulate the submission of this form? You can do
    that by sending out the appropriate headers with the form values in the body
    of the request:
    [color=blue][color=green]
    >> POST /cgi-bin/my.cgi HTTP/1.1
    >> Host: mysite
    >> Content-Type: application/x-www-form-urlencoded
    >> Content-Length: [work it out]
    >>
    >> ses=366021079
    >> id=somevalue[/color][/color]

    Not really a Javascript issue though, so perhaps I've totally misunderstood
    your problem.

    --
    Philip Ronan
    phil.ronanzzz@v irgin.net
    (Please remove the "z"s if replying by email)


    Comment

    Working...