Re: Document loaded:how to detect?
- From: "D.Campagna" <ynnadrebyc@xxxxxxxxxxxxx>
- Date: Tue, 14 Jul 2009 15:48:20 +0200
David Mark ha scritto:
I was talking about the fact that some of those articles credit my
ideas.
Yes, I noticed you was a pioneer in this field.
When you give advice, that's hardly trolling, of course. Everybody IMO
gives your deep knowledge the consideration that deserves.
That's my point. You seemed to indicate otherwise in the other post.
Just so we are clear on this.
OK. Troll is the wrong term and an offensive one. Can we say 'hard-skinned, vehement and [sometimes] corrosive man'? ;)
It is always best to find one way. I'm sure you don't need readyState
for what you want to accomplish.
Tried attachEvent, it works perfectly in IE. It seems I can drop readyState.
Yep, this was the reason.True is, I tried to use XMLHttpRequest at first, but then wasn't able to
manage the nationalized character set. You know, ìèòà... they are all
transformed in a 'exotic' character (but not by IE).
I'm afraid I don't follow. Do you mean that's why you are using an
IFrame?
Consider the following:
doc1.html is a normal HTML document:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
Questa è una frase in italiano
</body>
</html>
And then, my 'master' page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function getData(path)
{ if(window.XMLHttpRequest){ var p = new XMLHttpRequest();
}else{
var p = new ActiveXObject("Microsoft.XMLHTTP");
}
p.open("GET",path,false);
p.send(null);
var str=p.responseText;
document.getElementById("ST_div1").innerHTML=str
}
</script>
</head>
<body>
<div id="ST_div1">
i'm still empty
</div>
<button id="but01" onclick='getData("doc1.html")'>Getdata/XMLHttpRequest</button>
</body>
</html>
The whole idea is to load into the DIV different texts clicking on the corresponding button. The DIV has some features i like (it scrolls the text when moving the mouse, that's all, in fact) :^)
Now the problems are:
1) as someone pointed to me, many users don't allow activeX objects and
2) nationalized character sets don't render correctly.
So I dropped XMLHttprequest. Had I another solution?
oops.Actually I managed to use addEventListener if present. This technique
was only for FF, and I was unable to make it work, so I changed course.
You lost me again.
Let alone script injection, actually the code, in a nutshell, is:
-frdata = a reference to the frame 'container' of div and iframe
-frcmd = a reference to the frame 'container' of scripts
-my (hidden) iframe with the id 'hIframe'
-the DIV with the id "div01"
The button that should start the process of loading the iframe and transferring the content to the div is (in the main frame):
button id="but03" onclick='frcmd.loadIt("div01","doc1")'>Load it!</button>
In the command frame:
function loadIt(divName,htmlName){
var theIFrame=frdata.document.getElementById("hIframe");
if (theIFrame.src.indexOf(htmlName+".html")==-1){theIFrame.src=htmlName+".html"};
[.. omit attachEvent part, feature testing etc.]
if (document.addEventListener){
theIFrame.contentWindow.document.addEventListener('DOMContentLoaded',fillIt(divName,'hIframe'),false);
}
function fillIt(divName,iframeID){
frdata.document.getElementById(iframeID).innerHTML=frdata.document.getElementById(iframeID).contentWindow.document.body.innerHTML
The problem was (and still i'm not sure the solution is a workable one) that if I call fillIt() from loadIt(), the iframe's content still is not ready. So I need to determine when the iframe has fully loaded its content and then call fillit(). Actually I am considering to create dinamically and then remove the iframe because it seems that if the iframe is an HTML element of the main page, DOMContentLoaded is already 'true' when I add the event listener (but only in FF), and it does not work correctly. Can you enlighten?
(This is the reason for I investigate script injection too.)
the above... error is:
Do you have an idea why bugzilla gives me an 'uncaught exception' (FFWhat did you pass it?
3.0.11 on XP) when I call addEventListener?
[Exception... "Component returned failure code: 0x80040111 (NS_ERROR NOT AVAILABLE) [nsIChannel.contentType]" etc. but the script seems to work.
If you went through the entire post, many thanks. I tried to explain the better I can, but it's not easy. I will put the whole thing on a server in a couple of days.
No need to say I spent A LOT of time over this stuff... I'm a bit perplexed.
TIA
D. Campagna
.
- Follow-Ups:
- Re: Document loaded:how to detect?
- From: David Mark
- Re: Document loaded:how to detect?
- References:
- Document loaded:how to detect?
- From: D.Campagna
- Re: Document loaded:how to detect?
- From: Peter Michaux
- Re: Document loaded:how to detect?
- From: D.Campagna
- Re: Document loaded:how to detect?
- From: David Mark
- Re: Document loaded:how to detect?
- From: D.Campagna
- Re: Document loaded:how to detect?
- From: David Mark
- Document loaded:how to detect?
- Prev by Date: Re: Which shit key?
- Next by Date: Re: Crockford's 'The Good Parts' : a short review
- Previous by thread: Re: Document loaded:how to detect?
- Next by thread: Re: Document loaded:how to detect?
- Index(es):
Relevant Pages
|