我正在构建一个网络应用程序聊天。我想知道身份验证成功后如何将连接状态发送到下一页。网关将是登录页面。
登录.html
<html>
<script src="scripts/login.js"></script>
<script src="scripts/strophe.js"></script>
<form>
JID: <input type="text" name="username" id="username"><br/>
Password: <input type="password" name="password" id="password">
<input type="button" value="Connect" id="connect"/>
</form>
</html>
登录.js
var BOSH_SERVICE = "http://127.0.0.1:7070/http-bind/";
$(function{
var connection = new Strophe.Connection(BOSH_SERVICE);
var jid = $('#username').val();
var password = $('#password').val();
//connection
connection.connect(jid, password, callback());
});
function callback(status){
//authentication code here
else if(status==Strophe.Status.CONNECTED){
log(connected);
windows.location = "chat.html";
}
}
如何使会话保持活动状态,以便当页面重定向到 chat.html 时它仍然可以连接。谢谢。很快就需要帮助。