Foros del Web » Programando para Internet » Jquery »

Chat con Jquery y php no me funciona en IE6 e IE7

Estas en el tema de Chat con Jquery y php no me funciona en IE6 e IE7 en el foro de Jquery en Foros del Web. Aca pongo el codigo de mi index, que es el que no funciona, al parecer internet explorer me dice que tengo un error en esta ...
  #1 (permalink)  
Antiguo 18/08/2009, 09:07
(Desactivado)
 
Fecha de Ingreso: enero-2008
Ubicación: Mendoza
Mensajes: 458
Antigüedad: 16 años, 3 meses
Puntos: 2
Exclamación Chat con Jquery y php no me funciona en IE6 e IE7

Aca pongo el codigo de mi index, que es el que no funciona, al parecer internet explorer me dice que tengo un error en esta parte:

parte del javascript..
Código PHP:
function loadLog(){
        var 
oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
        $.
ajax({
        
url"log.html",
        
cachefalse,
            
success: function(html){
            $(
"#chatbox").html(html);
            var 
newscrollHeight = $("#chatbox").attr("scrollHeight") - 20
                if(
newscrollHeight oldscrollHeight){
                $(
"#chatbox").animate({ scrollTopnewscrollHeight }, 'normal');
                }
            },
        });
    } 
Ahora en Firefox y en chrome funciona perfecto... me dan una mano para hacerlo fucionar en ie6 e ie7 y luego pongo todo los codigos completos para los que quieran un chat sencillo y facil de modificar...


Codigo completo del index.php
Código PHP:
<?
session_start
();

if(isset(
$_GET['logout'])){
    
$fp fopen("log.html"'a');
    
fwrite($fp"<div class='msgln'><i>User "$_SESSION['name'] ." has left the chat session.</i><br></div>");
    
fclose($fp);
    
session_destroy();
    
header("Location: index.php");
}

function 
loginForm(){
    echo
'
    <div id="loginform">
    <form action="index.php" method="post">
    <p>Please enter your name to continue:</p>
    <label for="name">Name:</label>
    <input type="text" name="name" id="name" />
    <input type="submit" name="enter" id="enter" value="Enter" />
    </form>
    </div>
    '
;
}
if(isset(
$_POST['enter'])){
    if(
$_POST['name'] != ""){
    
$_SESSION['name'] = stripslashes(htmlspecialchars($_POST['name']));
    }else{
    echo 
'<span class="error">Please type in a name</span>';
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Chat - Customer Module</title>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<?php
if(!isset($_SESSION['name'])){
    
loginForm();
}else{
?>
    <div id="wrapper">
    <div id="menu">
    <p class="welcome">Welcome, <b><?php echo $_SESSION['name']; ?></b></p>
    <p class="logout"><a id="exit" href="#">Exit Chat</a></p>
    <div style="clear:both"></div>
    </div>
    <div id="chatbox">
<?php
if(file_exists("log.html") && filesize("log.html") > 0){
    
$handle fopen("log.html""r");
    
$contents fread($handlefilesize("log.html"));
    
fclose($handle);
    echo 
$contents;
}
?>
</div>
<form name="message" action="">
<input name="usermsg" type="text" id="usermsg" size="63" />
<input name="submitmsg" type="submit"  id="submitmsg" value="Send" />
</form>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    setInterval (loadLog, 2500);
    function loadLog(){
        var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
        $.ajax({
        url: "log.html",
        cache: false,
            success: function(html){
            $("#chatbox").html(html);
            var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20; 
                if(newscrollHeight > oldscrollHeight){
                $("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal');
                }
            },
        });
    }

    $("#submitmsg").click(function(){
        var clientmsg = $("#usermsg").val();
        $.post("post.php", {text: clientmsg});
        $("#usermsg").attr("value", "");
        return false;
    });
    $("#exit").click(function(){
        var exit = confirm("Are you sure you want to end the session?");
        if(exit==true){
        window.location = 'index.php?logout=true';
        }
    });
});
</script>
<?php
}
?>
</body>
</html>
  #2 (permalink)  
Antiguo 18/08/2009, 13:16
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Respuesta: Chat con Jquery y php no me funciona en IE6 e IE7

Hola,
El error es que pusiste una coma de mas:
Código javascript:
Ver original
  1. function loadLog(){
  2.         var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
  3.         $.ajax({
  4.         url: "log.html",
  5.         cache: false,
  6.             success: function(html){
  7.             $("#chatbox").html(html);
  8.             var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
  9.                 if(newscrollHeight > oldscrollHeight){
  10.                 $("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal');
  11.                 }
  12.             }, // <--------- IE toma como error si te pasas una coma.
  13.         });
  14.     }
Suerte
Salu2
__________________
Half Music - www.halfmusic.com
  #3 (permalink)  
Antiguo 18/08/2009, 13:19
Avatar de goyo_  
Fecha de Ingreso: agosto-2009
Mensajes: 91
Antigüedad: 14 años, 8 meses
Puntos: 1
Respuesta: Chat con Jquery y php no me funciona en IE6 e IE7

Cita:
Iniciado por pato12 Ver Mensaje
Hola,
El error es que pusiste una coma de mas:
Código javascript:
Ver original
  1. function loadLog(){
  2.         var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
  3.         $.ajax({
  4.         url: "log.html",
  5.         cache: false,
  6.             success: function(html){
  7.             $("#chatbox").html(html);
  8.             var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
  9.                 if(newscrollHeight > oldscrollHeight){
  10.                 $("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal');
  11.                 }
  12.             }, // <--------- IE toma como error si te pasas una coma.
  13.         });
  14.     }
Suerte
Salu2
Que buena vision, el infame -> },
  #4 (permalink)  
Antiguo 18/08/2009, 13:56
(Desactivado)
 
Fecha de Ingreso: enero-2008
Ubicación: Mendoza
Mensajes: 458
Antigüedad: 16 años, 3 meses
Puntos: 2
Exclamación Respuesta: Chat con Jquery y php no me funciona en IE6 e IE7

Bajo la lupa...

Muy bueno.. muchas gracias, realmente no encontraba el problema...

Les parece que suba el script completo para quien lo quiera lo use... es un chat hecho en jquery y php, un totorial de www.elwebmaster.com

aqui la dire...

http://www.elwebmaster.com/articulos...n-php-y-jquery
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:42.