不使用Javascript你不能做到这一点。在Javascript中你就可以说:
top.location.href = "http://go.wherever";
现在我从您的意见得到的是以下情况:
您创建服务HTML页面到客户自己的HTTP服务器应用程序。
这就是说,您的客户目前没有任何逻辑。你应该了解的WebSockets:https://en.wikipedia.org/wiki/WebSocket和https://developer.mozilla.org/en/docs/Web/API/WebSocket
你需要的是更多或更少以下(抽象):
您的服务器:
HTTPServer.ServeHTMLPage(htmlPage);
WSServer.WaitForIncomingSockets();
用户的浏览器:
<html>
<head><title>Waiting Room</title></head>
<body>
please wait for the game to start
<script type="text/javascript">
var ws = new WebSocket(someUrl);
ws.addEventListener("message", function(e){
// handle incoming data
}
// connect to the server and keep the connection open
</script>
</body>
</html>
当所有客户端都准备好后,通过websocket将消息发送给所有等待的用户。尽管如此,你将不得不实施你自己的协议。
来源
2017-03-04 18:32:21
Psi
我可以使用Javascript。 但是我如何在我的代码中使用它?' –
我看不到你的代码,也许你应该在你的问题中提供一些代码 – Psi
我添加了等候室的代码 –