...

View Full Version : Can you make this script x-browser compatable...



missing-score
04-13-2003, 09:14 PM
Right, I have this chatroom that I made with PHP, and krycek suggested that I do something about it to stop the flicker on the iframe.

He made this script...



function chatLoad() {
if (parent.mess.document.readyState == "complete") {
parent.mess.document.location = 'messages.php';
}
timer = window.setTimeout("chatLoad()", 4500);
chatRefresh();
}
chatLoad();
function chatRefresh() {
if (parent.mess.document.readyState != "complete") {
// readyState can be; uninitialized, loading, loaded, interactive, or complete
timer = window.setTimeout("chatRefresh()", 4000);
} else {
var html = parent.mess.document.body.innerHTML;
chat.innerHTML = html;
}
}


mess is the name of my iframe

chat is the name of my div to load the chat into.


It works fine, you can have a look: www.itk-network.com/box, but I would appreciate it if someone could help me make this cross browser compatable. :)

joh6nn
04-14-2003, 03:15 PM
at first glance, it looks compatible to me. is it not working in a certain brower?

missing-score
04-14-2003, 04:31 PM
It doesnt work in Mozilla.

beetle
04-14-2003, 04:44 PM
According to my reference (http://www.mozilla.org/docs/dom/domref/dom_doc_ref.html#1022427), there is no readyState property to document in the Gecko DOM.

Must be an IE-only (http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/readystate_1.asp) thing

missing-score
04-14-2003, 07:48 PM
Right, thanks...

In that case, is there another way to get the same effect?

krycek
04-14-2003, 08:05 PM
thanks matt for giving me credit there :thumbsup:

I wrote that script kinda quick so I didn't have chance to worry about compatibility.

beetle is right about readystate - and I don't know of a x-browser alternative, or I would have given one first time round :(

any ideas about how to duplicate the effect of readystate (i.e. how to tell that the page has finished loading within the iframe) would be great :D

::] krycek [::

krycek
04-14-2003, 08:19 PM
LOL stupid me! :slaphead:

Matt, just put a call to the JS function inside the page you are loading. When the page has loaded in the iframe, it will call the function etc.

I'm sure you can integrate it easily enough :)

::] krycek [::

scroots
04-14-2003, 08:21 PM
a barmy thought
at the end of the I frame page
<script>
parent.document.foo():
</script>

in the main page
<script>
function foo(){
alert("page has loaded")
}
</script>

or simply at the end of the I frame page
<script>
alert("page has loaded")
</script>

scroots

missing-score
04-14-2003, 08:22 PM
That seems so obvious now.

Thanks for all your help krycek.

missing-score
04-14-2003, 08:23 PM
And scroots, who posted at about the same time :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum