|
Answer» For some reason, document.getElementById("D1") is returning null... And it's clearly on the PAGE..
Code: [Select]<iframe id="D1" style="width:100px; height:100px; border:1px black solid; display:none;" src="Get.php?ID=1"> </iframe> <div id="ReadURL" name="ReadURL"> <?php $ID = $_GET['ID']; $user = $_COOKIE['usern']; if(!$user) { $user = "Guest"; } if(file_exists("Chat/$ID.php")) {
} else { $A = fopen("Chat/$ID.php", "w"); FWRITE($A, "<script type=\"text/javascript\"> function reload(t) { if(!t) { if(!document.getElementById('D1')) { ALERT('null 2'); return FALSE; } document.getElementById('D1').src = document.getElementById('D1').src; // D1 is an IFrame. setTimeout('reload(\'true\')', 1000); } else { if(!document.getElementById('D1')) { alert('null 1'); return false; } if(document.getElementById('D1').document.getElementById('ReadURL').innerHTML != document.getElementById('ReadURL').innerHTML) { alert('false'); window.location.reload(true); } else { setTimeout('reload()', 1000); } } } setTimeout('reload()', 2500); </script>Welcome. To get started, type something in the chat box below."); } echo file_get_contents("Chat/$ID.php"); ?>
</div> What is this line supposed to do?
Code: [Select]document.getElementById('D1').src = document.getElementById('D1').src; And:
Code: [Select]!document.getElementById('D1') Have you checked the spec for getElementById()? Can you negate it?
I have to say once more, the javascript prototype library makes this kind of stuff much easier. "$('id')" instead of "document.getElementById('id')". Nice. http://prototypejs.org/
Also, using the DEBUG console of the Web Developer plugin for Firefox is a lifesaver.
|