如何在 html 中调用 perl 脚本
How to call a perl script in html
如何调用返回数据的 perl 脚本 "text" 在 html 中键入 file.Posting reference.This 脚本的 perl 脚本必须在 index.html 那么该怎么做
#!/usr/bin/perl -w
use CGI;
my $cgi = CGI->new;
my $remote = $cgi->remote_host();
my $AB = "16.108";
my $CD = "16.214";
my $EF = "10.99";
my $GH = "10.243";
my $XY = "10.179";
my @remote_ip_values = split(/\./, $remote);
my $remote_ip = $remote_ip_values[0] .".". $remote_ip_values[1];
print "Content-type: text/html\n\n";
print "document.write(\"<style>\n\");\n";
print "document.write(\"font color:red;\n\");\n";
if ($remote_ip eq $AB)
{
print "document.write(\"SUCCESSFUL\");\n";
}
else
{
print "document.write(\"TEST\");\n";
}
exit;
我正在编辑我的答案,因为我现在明白你想做什么。我已经设置了一个简单的示例,它将从 "another website" - 加载内容,这对您来说 将是您的 Perl CGI。
这个HTML使用了一些简单的JQuery。我正在加载以下 HTML 页面,http://chocksaway.com/tester.html 并将内容复制到 "test" div:
<!DOCTYPE HTML>
<html>
<head>
<title>Loader</title>
</head>
<body>
<div id="test"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#test').load('http://chocksaway.com/tester.html');
});
</script>
</body>
</html>
http://chocksaway.com/tester.html 具有以下 HTML:
<html>
<header></header>
<body>
this is a test so there
</body>
</html>
如果你打开你http://chocksaway.com/tester2.html,你会看到:
this is a test so there
将“http://chocksaway.com/tester2.html”替换为您的 Perl CGIURL。
如何调用返回数据的 perl 脚本 "text" 在 html 中键入 file.Posting reference.This 脚本的 perl 脚本必须在 index.html 那么该怎么做
#!/usr/bin/perl -w
use CGI;
my $cgi = CGI->new;
my $remote = $cgi->remote_host();
my $AB = "16.108";
my $CD = "16.214";
my $EF = "10.99";
my $GH = "10.243";
my $XY = "10.179";
my @remote_ip_values = split(/\./, $remote);
my $remote_ip = $remote_ip_values[0] .".". $remote_ip_values[1];
print "Content-type: text/html\n\n";
print "document.write(\"<style>\n\");\n";
print "document.write(\"font color:red;\n\");\n";
if ($remote_ip eq $AB)
{
print "document.write(\"SUCCESSFUL\");\n";
}
else
{
print "document.write(\"TEST\");\n";
}
exit;
我正在编辑我的答案,因为我现在明白你想做什么。我已经设置了一个简单的示例,它将从 "another website" - 加载内容,这对您来说 将是您的 Perl CGI。
这个HTML使用了一些简单的JQuery。我正在加载以下 HTML 页面,http://chocksaway.com/tester.html 并将内容复制到 "test" div:
<!DOCTYPE HTML>
<html>
<head>
<title>Loader</title>
</head>
<body>
<div id="test"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#test').load('http://chocksaway.com/tester.html');
});
</script>
</body>
</html>
http://chocksaway.com/tester.html 具有以下 HTML:
<html>
<header></header>
<body>
this is a test so there
</body>
</html>
如果你打开你http://chocksaway.com/tester2.html,你会看到:
this is a test so there
将“http://chocksaway.com/tester2.html”替换为您的 Perl CGIURL。