hsimberg Postado Abril 15, 2006 Denunciar Share Postado Abril 15, 2006 ae gentetenho um chate gostaria que assim que mandasse a mensagem e postasse, fizesse um 'focus' no lugarque manda mensagem ... pro usuario não ter que pegar o mouse e clicar la pra poder escrever de novo...entenderam? alguém sabe?o codigo ta mais ou menos assim<?php session_start(); require "../login_db.php"; $handle = $_SESSION['login']; if(isset($handle)){ // // The world's least efficient wall implementation // require("Sajax.php"); function add_line($msg) { $f = fopen("wall.html", "a"); $dt = date("d/m - G:i:s"); $msg = strip_tags($msg); $msg = wordwrap( $msg, 75, "<br>", 1); #$msg = strip_tags(stripslashes($msg)); # $login = $_SESSION['login']; $c = mysql_query("SELECT * FROM members WHERE login = '$login'"); $user_d = mysql_fetch_array($c); $name_completo = $user_d["first_name"]." ".$user_d["last_name"]; $img_user = $user_d["dp"]; $flag = $user_d["location"]; # fwrite($f, "<table width=100% border=1 align=center cellpadding=0 cellspacing=0 bordercolor=#CCCCCC style=border-collapse: collapse;> <tr> <td><table width=100% > <tr> <td width=4% rowspan=2 valign=top><img src=../thumb/$img_user><br></td> <td width=96% valign=top><table width=100% > <tr> <td><em><strong>$name_completo</strong> on $dt says:</em></td> </tr> <tr> <td>$msg</td> </tr> <tr> <td align=right><img src=../img/flag/$flag.gif></td> </tr> </table> </td> </tr> </table></td> </tr> </table><br>"); fclose($f); } function refresh() { ############################# ################## $login = $_SESSION['login']; $time = time(); $now = date("G:i:s"); ##chega se já existe depois adiciona se não tiver $onm = mysql_query("SELECT * FROM chat WHERE mfrom='$login'"); $con = mysql_num_rows($onm); if($con==0){ mysql_query("INSERT INTO chat (mfrom,hour,time) VALUES ('$login','$now','$time')"); } else { ########## atualiza;) mysql_query("UPDATE chat SET time = $time, hour = '$now' WHERE mfrom = '$login'"); ################## } ############################# $time = time(); $date = date("d/m/Y @ G:i:s"); $ip =$_SERVER['REMOTE_ADDR']; $url = $_SERVER['REQUEST_URI']; $sql = "UPDATE members SET last_url = '$url', time = '$time', last_visit = '$date', last_ip = '$ip' WHERE login = '$login'"; $busca = mysql_query($sql); ############################### $lines = file("wall.html"); // return the last 25 lines return join("\n", array_slice($lines, -215)); } $sajax_request_type = "GET"; sajax_init(); sajax_export("add_line", "refresh"); sajax_handle_client_request(); ?> <html> <head> <title>Schoenstatt Youth <? echo date("Y");?></title> <script language="javascript"> function Profile(aURL, W, L) { window.open(aURL,'', 'width='+W+', height='+L+', top=0, left=0, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no'); } </script> <script> <? sajax_show_javascript(); ?> var check_n = 0; var old_data = "--"; function refresh_cb(new_data) { if (new_data != old_data) { document.getElementById("wall").innerHTML = new_data; setTimeout("refresh()", 1000); old_data = new_data; } else { setTimeout("refresh()", 2500); } // ################ document.getElementById("status").innerHTML = "Checked #" + check_n++; } function refresh() { // ############## document.getElementById("status").innerHTML = "Checking.."; x_refresh(refresh_cb); } function add_cb() { // we don't care.. } function add() { var line; var handle; handle = document.getElementById("handle").value; line = document.getElementById("line").value; if (line == "") return; sajax_request_type = "POST"; x_add_line(line, add_cb); document.getElementById("line").value = ""; } </script> <link href="../style.css" rel="stylesheet" type="text/css"> </head> <body topmargin="0" bottommargin="0" onload="refresh();"> <form name="f" action="#" onsubmit="add();return false;"> <table align="center" background="../img/bg_1.gif" > <tr> <td><div id="wall"></div></td> </tr> <tr><td align="center">who is online: <? ###################################################### $p_time = time(); $tim = $p_time-50; $ac = mysql_query("SELECT * FROM chat WHERE time >= $tim"); while ($who = mysql_fetch_array($ac)){ $on_m = $who["mfrom"]; $x = mysql_query("SELECT * FROM members WHERE login = '$on_m'"); $on = mysql_fetch_array($x); ?> [<a href="java script:Profile('../e_member.php?id=<? echo $on["id"]; ?>','480','350')"><strong><? echo $on["first_name"]; ?></strong></a>] <? } ##################################################### ?> <a href="./"><img src="../img/refresh.gif"></a></td></tr> <tr align="center"> <td> <? $c = mysql_query("SELECT * FROM members WHERE login = '$login'"); $name = mysql_fetch_array($c); ?> <input type="text" class="whiteborder" name="handle" id="handle" disabled value="<? echo $name["first_name"]." ".$name["last_name"]; ?>" onFocus="this.select()" style="width:130px;"> <input type="text" name="line" id="line" onfocus="this.select()" style="width:300px;"> <input type="button" name="check" value="Send Message" onclick="add(); return false;"> <input type="reset" name="Reset" value="Exit" onclick="java script:window.close()"></td> </tr> </table> </form> <a name="last"></a> </body> </html> <? } else { header("Location: ../index.php"); } ?>alguma ideia? Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 fercosmig Postado Abril 16, 2006 Denunciar Share Postado Abril 16, 2006 document.nome_do_form.nome_do_input.focus(); Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
hsimberg
ae gente
tenho um chat
e gostaria que assim que mandasse a mensagem e postasse, fizesse um 'focus' no lugarque manda mensagem ... pro usuario não ter que pegar o mouse e clicar la pra poder escrever de novo...entenderam? alguém sabe?
o codigo ta mais ou menos assim
alguma ideia?
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.