Boa tarde amigos eu gostaria de saber se tem como sair da pagina em asp quando a pagina for fechada. pois não quero colocar um botão de sair pois outras pessoas poderam fechala sem quere o script e este abaixo
<%
Option Explicit
Dim sql,username,rsUser,rsMessages,newcount
username = Request.Cookies("username")
'If the username cookie is set, they must have logged in, so get their details from the database
if username <> "" then
%>
<!--#include file="conn.asp"-->
<%
sql = "SELECT icon FROM Users WHERE username = '" & username & "'"
Set rsUser = Server.CreateObject("ADODB.Recordset")
rsUser.Open sql, conn, 3, 3
sql = "SELECT messageread FROM messages WHERE sendto = '" & username & "'"
Set rsMessages = Server.CreateObject("ADODB.Recordset")
rsMessages.Open sql, conn, 3, 3
newcount = 0
if not rsMessages.EOF then
rsMessages.Movefirst
do until rsMessages.EOF
if rsMessages("messageread") = False then
newcount = newcount + 1
end if
rsMessages.Movenext
loop
rsMessages.Movefirst
end if
end if
%>
<html>
<head>
<script language="JavaScript">
<!-- hide on
function popup(popupfile,winheight,winwidth)
{
open(popupfile,"PopupWindow","resizable=no,height=" + winheight + ",width=" + winwidth + ",scrollbars=no");
}
// hide off -->
</script>
<title>Homepage</title>
</head>
<body bgcolor="#FFFFFF" link="#DD0000" vlink="#DD0000" alink="#000000">
<font face="arial,helvetica" size=2>
<h3 align="center"></h3>
<table width="180" cellpadding=3 cellspacing=0 border=0 bordercolor="#000000" align="CENTER">
<%'If they're not logged in, then display a login box
if username = "" then%>
<tr>
</tr>
<tr>
<form name="login" action="signin.asp" method="post">
<input type="hidden" name="page" value="index1.asp">
</form>
</tr>
<%'If they are, show a mini profile box plus a sign out link
else%>
<tr>
<td bgcolor="#FFFFFF"> <font face="arial,helvetica" size=1><b> <img src="icons/<%=rsUser("icon")%>.gif" width=50 height=50 align="right">
<font size="2">Voce esta falando com <%=username%>.</font><br>
</b></font> </td>
</tr>
<%
rsUser.close
set rsUser = nothing
rsMessages.close
set rsMessages = nothing
conn.close
set conn = nothing
end if
%>
</table>
</font>
</body>
</html>
Pergunta
arldin
Boa tarde amigos eu gostaria de saber se tem como sair da pagina em asp quando a pagina for fechada. pois não quero colocar um botão de sair pois outras pessoas poderam fechala sem quere o script e este abaixo
<% Option Explicit Dim sql,username,rsUser,rsMessages,newcount username = Request.Cookies("username") 'If the username cookie is set, they must have logged in, so get their details from the database if username <> "" then %> <!--#include file="conn.asp"--> <% sql = "SELECT icon FROM Users WHERE username = '" & username & "'" Set rsUser = Server.CreateObject("ADODB.Recordset") rsUser.Open sql, conn, 3, 3 sql = "SELECT messageread FROM messages WHERE sendto = '" & username & "'" Set rsMessages = Server.CreateObject("ADODB.Recordset") rsMessages.Open sql, conn, 3, 3 newcount = 0 if not rsMessages.EOF then rsMessages.Movefirst do until rsMessages.EOF if rsMessages("messageread") = False then newcount = newcount + 1 end if rsMessages.Movenext loop rsMessages.Movefirst end if end if %> <html> <head> <script language="JavaScript"> <!-- hide on function popup(popupfile,winheight,winwidth) { open(popupfile,"PopupWindow","resizable=no,height=" + winheight + ",width=" + winwidth + ",scrollbars=no"); } // hide off --> </script> <title>Homepage</title> </head> <body bgcolor="#FFFFFF" link="#DD0000" vlink="#DD0000" alink="#000000"> <font face="arial,helvetica" size=2> <h3 align="center"></h3> <table width="180" cellpadding=3 cellspacing=0 border=0 bordercolor="#000000" align="CENTER"> <%'If they're not logged in, then display a login box if username = "" then%> <tr> </tr> <tr> <form name="login" action="signin.asp" method="post"> <input type="hidden" name="page" value="index1.asp"> </form> </tr> <%'If they are, show a mini profile box plus a sign out link else%> <tr> <td bgcolor="#FFFFFF"> <font face="arial,helvetica" size=1><b> <img src="icons/<%=rsUser("icon")%>.gif" width=50 height=50 align="right"> <font size="2">Voce esta falando com <%=username%>.</font><br> </b></font> </td> </tr> <% rsUser.close set rsUser = nothing rsMessages.close set rsMessages = nothing conn.close set conn = nothing end if %> </table> </font> </body> </html>Tem como fazer
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.