我创建了一个从列表中随机打开网站的简单脚本。我最近尝试添加一项功能,使用户可以选择每页打开和关闭之间的等待时间(以毫秒为单位)。这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>Smokescreen</title>
</head>
<body align="center" style="font-family:monospace">
<h2 align="center" style="font-family:monospace">
SmokeScreen
</h2>
<h3 align="center" style="font-family:monospace">
SmokeScreen is a JavaScript program that opens a random site every 3 seconds,
</h3>
<h3 align="center" style="font-family:monospace">
to create a "smokescreen" over your browser history, preventing anyone from [easily] finding your information.
</h3>
<h4 align="center" style="font-family:monospace">To exit, close the original window that has the text "Smokescreen" in the title.</h4>
<p align="center" style="font-family:monospace">
<a href="github.com/keeganjk/smokescreen" style="font-family:monospace" align="center">Source Code / Learn More</a>
<br />
<div style="width: 300px; border: 25px solid #800000; margin:0 auto; font-family:monospace;" align="center">
<h4 align="center" style="font-family:monospace">Milliseconds to wait before closing page:</h4>
<h4 id="one" align="center" style="font-family:monospace"></h4>
<button onclick="millisecs = prompt('New time to wait (in milliseconds)?'); if ( isNaN(milliseconds) ) {millisecs = millisecsBackup} else {millisecsBackup = millisecs} document.getElementById('one').innerHTML = millisecs;" style="font-family:monospace" align="center">Set Wait Time</button>
<br />
<br />
</div>
<br />
<div style="margin:0 auto; font-family:monospace" align="center">
<button onclick="getRandom(0, list.length, millisecs);" style="font-family:monospace" align="center">Start!</button>
</div>
</p>
<script src="script.js"></script>
<script>
var millisecs = 3000;
var millisecsBackup = 3000;
document.getElementById("one").innerHTML = millisecs;
</script>
</body>
</html>
由于某些原因,当我输入不同的数字时,h4
中id
one
@Path("/restServer")
public class RestServer {
public static final Logger LOG = LoggerFactory.getLogger(BackendServer.class);
@POST
@Path("/createUser")
@Produces(MediaType.TEXT_PLAIN)
public String createUser(@HeaderParam("authorization") String authString) {
String decodedAuth = "";
String[] authParts = authString.split("\\s+");
String authInfo = authParts[1];
byte[] bytes = Base64.decodeBase64(authInfo);
decodedAuth = new String(bytes);
String credentials[] = decodedAuth.split(":");
String username = credentials[0];
String password = credentials[1];
UserDAOImpl user = new UserDAOImpl();
user.addUser(username, password);
return decodedAuth;
}
的文字不会更新。我做错了什么?
答案 0 :(得分:0)
您正在检查if (isNaN(milliseconds))
但是您调用了变量millisecs
,因此它会抛出错误。
如果您使用的是现代浏览器,请尝试打开开发人员工具(Windows上的F12 + Mac上的CMD + OPT + i)并检查控制台。
另请注意将内联样式/ onclicks移至<style>
和<script>
标记:)