Jump to content

Refreshing Div IE7/8 Problems


x2i

Recommended Posts

Hi, I have a code that refreshes a chat box every 10 seconds and it works an absolute treat in Firefox 3.5, however in IE7/8 it doesn't wish to co-operate. It doesn't reload the div and whats worse is that even hitting CTRL+F5 will refresh it properly - yet if you navigate to the page that holds the chat entries outside of the chat box it works - then when you go back to the chatbox it will reload.  Can someone help me out if possible?

 

<script type="text/javascript">
hova = false;
var jahtimer;

function jahDone(target) {
    // only if req is "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            results = req.responseText;
            document.getElementById(target).innerHTML = results;
        } else {
            document.getElementById(target).innerHTML = "jah error:\n" + req.statusText;
        }
    }
}

function jah(url, target) {
    if(hova === false) {
    // native XMLHttpRequest object
        document.getElementById(target).innerHTML = '<span class="ajah_waiting"><a href="java script:jah(\''+url+'\',\''+target+'\');"><br \/><img src=\"images/loadingchat.gif\" style=\"height:30px;width:30px;border:0;\" \/><br \/>Refreshing...<\/a><\/span>';
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {
            jahDone(target);
        };
        req.open("GET", url, true);
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {
                jahDone(target);
            };
            req.open("GET", url, true);
            req.send();
        }
    }
  }
}

function startInterval() {
    jah('chatget.php?limit=<?php echo $limit; ?>','chat');
    jahtimer = setInterval('jah(\'chatget.php?limit=<?php echo $limit; ?>\',\'chat\');', 10000);
}

//function jah_switch(url, target) {
    //if (document.getElementById(target).innerHTML !== '') {
        //document.getElementById(target).innerHTML = '';
    //} else {
        //jah(url, target);
    //}
//}
</script>

<div id="chat" align="center"></div>

 

 

The chat box can be located here: http://www.x2i4eva.com/chat.php

Link to comment
Share on other sites

Sorry for double posting since I cannot edit my post again ¬_¬

 

When I run it through this website: http://www.jslint.com/

I get this result... I don't know if this is what is causing it but still:

 

 

Implied global: ActiveXObject 31, hova 2 19, req 7 9 10 13 23 24 27 28 31 32 33 36 37, results 10 11, window 22 30

 

Problem at line 45 character 16: Implied eval is evil. Pass a function instead of a string.

 

jahtimer = setInterval('jah(\'chatget.php?limit=<?php echo $limit; ?>\',\...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.