我发现了一个脚本并做了许多更改,其中包括放置HTML以通过网页运行脚本。从网页内部,我如何在不使用提示等的情况下运行脚本。我确信我正在做一些根本性错误的事情。热身脚本JavaScript
<!DOCTYPE HTML>
<html>
<head>
<title>Volume</title>
</head>
<body>
<h1>Warmup Script</h1>
<script>
function warmup() {
warmUpSite("http://TestWebSite.com");
}
function warmUpSite(url) {
console.info("warming up: " + url);
var req = require('request');
req.get({ url: url }, function(error, response, body) {
if (!error) {
alert("hot hot hot! " + url);
} else {
alert('error warming up ' + url + ': ' + error);
}
});
}
</script>
</body>
</html>
那么你不是在调用你的函数。某处你应该有一个'warmup()'调用。 – epascarello