I think the previous two posters missed the direction of your question, but on the other side, you didn't provide any useful examples. So my interpretation of your question is as follows :
- You have a website that sends a (HTML) page with some JavaScript code in it that is triggered by an onClick JavaScript event. Said code submits a form on the page back to the server.
This is easily emulated in Perl, see for example many scripts on this site using LWP::Simple or LWP::UserAgent (search via Super Search).
- Or you have a website that sends some HTML with is then manipulated in the browser with JavaScript and displayed differently based on some decisions made by the JavaScript code.
This would be much harder or impossible to emulate in Perl, as to emulate JavaScript, you have to write a complete JavaScript emulator in Perl, something which is quite nasty.
- A third possibility could be that you want to remotely control and/or automate your browser. For that purpose, on Windows, have a look at the Internet Explorer automation stuff via Win32::OLE and/or Win32::API, most likely the SendMessage() API (not for the faint of heart though, sending events to other processes can result in interesting behaviour of the whole system)
Maybe these interpretations help you to reformulate your question to match your intentions.
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The
$d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider
($c = $d->accept())->get_request(); $c->send_response( new #in the
HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
| [reply] [d/l] |
Hello again!
There is some server-side javascript code in html file I've dumpped from some web page
by using LWP::UserAgent, HTTP::Request and HTTP::Response... The problem is that I must
click on a button to initiate executing query (there is no link I could parse and call it)
directly... so there is probablly only one chance to use Javascript module (wrappers
around libjs) before I dig in libjs sources and try to find out how does mozilla
communicate with http servers...
Thx, anyway.
| [reply] |
the javascript you get by retrieving the code of a file using LWP::UserAgent is client-side javascript,not server-side.
i should point out that , contrary to what ignatz said about Microsoft products using server-side Javascript, that s not quite correct. Server-side javascript can be used only with Netscape-specific application servers. ASP and IIS use server-side VBScript and Jscript , not Javascript.JScript is Microsoft's version of Javascript,however it does not work with Netscape browsers.
| [reply] |
JavaScript code in a web page that you can see by viewing its source isn't server-side JavaScript. While it does reside on the server, it is passed to the client and executes on the client. Very few web servers use server-side JavaScript (M$ web servers though ASP and Netscape being the two that come to mind) and if they were you wouldn't be able to see the code in action by viewing the source of the web page only by viewing the code that generated the HTML that you are viewing.
()-()
\"/
` | [reply] |
Javascript: clientside (in your web browser)
Perl: serverside (on the webserver)
The only way you are going to get anything like an on click is to use an anchor and link to a cgi directly:
<a href="program.cgi">Click here</a>
or (untested but would only work on IE)
<img src="blah.gif" onClick="self.location=program.cgi">
But you really want to avoid the latter example.
| [reply] [d/l] |