1

我正在使用以下 Perl 片段来执行使用 MozRepl 的 JavaScript 函数。但是,我收到错误消息“MozRepl::RemoteObject: TypeError: myFunction is not a function at test.pl line 16”。我究竟做错了什么?

use v5.10;
use WWW::Mechanize::Firefox;
use strict;
use warnings;

my $mech = WWW::Mechanize::Firefox->new();
$mech->update_html(<<HTML);
<script type="text/javascript">
function myFunction() {
    alert("Hello World!");
}
</script>
HTML

sleep 2;
$mech->eval_in_page( 'myFunction();' );
4

0 回答 0