包括Perl CGI Javascript,但警报没有发生

Perl CGI Javascript included but the alert is not happening

本文关键字:Perl CGI Javascript 包括      更新时间:2023-09-26
#!/usr/bin/perl -w
use warnings;
use diagnostics;
use CGI::Carp 'fatalsToBrowser';
use CGI qw(-debug);
use CGI ':standard';
print header(),
   start_html(-title => "OutSide File", -script   =>{-type=>"text/javascript",-src=>"javascript/javafile.js"}),
'<a href="#" onmouseOver="testfunc()"> mouse On </a>',
   end_html;

javafile.js is -

function testfunc(){
 alert("File")
}

测试函数在屏幕上没有警报

我用

perl test.pl >test.html

并在火狐和IE中打开了生成的文件。警报完美显示。

一些问题,可能会阻止警报发生

  • 目录层次结构错误,javafile.js必须位于javascript子目录中
  • Javascript 被 Noscript (Firefox) 抑制或在相应的安全区域 (IE) 中禁用