Perl WWW::Scripter, calling javascript from .js file
The main html file contains following javascript source
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Hello Worlds</title>
<link rel="stylesheet" href="css/main_page.css" type="text/css"/>
<link rel="stylesheet" href="css/page_content.css" type="t开发者_如何学Cext/css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/main_page.js"></script>
<script type="text/javascript" src="js/page_content.js"></script>
<script type="text/javascript" src="js/configurator.js"></script>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
one of the form's post called a javascript function which belongs to page_content.js
file.
I am trying to inovke the function using following
$scripter->get('javascript:submitForm()');
but it's not working. Please help me how can I call the function which belongs to the page_content.js
file.
If the html page (with address stored in $url
) contains (internally or externally) JavaScript that define function/procedure submitForm() then you can execute it by the following code:
use WWW::Scripter;
$w = new WWW::Scripter;
$w->use_plugin('JavaScript');
$w->get($url);
$w->eval('submitForm();');
For more information see WWW::Scripter documentation.
精彩评论