Re: Document loaded:how to detect?



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.

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?
Yep, this was the reason.
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?

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.
oops.
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.)


Do you have an idea why bugzilla gives me an 'uncaught exception' (FF
3.0.11 on XP) when I call addEventListener?
What did you pass it?
the above... error is:
[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
.



Relevant Pages

  • Re: Setting the scroll bar to a certain level?
    ... I dont understand quite well your problem but there is a way to scroll ... a div or a iframe to certain position ... with a frame or iframe or page: ... where you do have a frame inside ...
    (comp.lang.javascript)
  • Iframe menu help
    ... I have created a menu from a div, inside an iframe. ... This i frame is ... lot with the div styles but failed to display the whole menu. ...
    (comp.lang.javascript)
  • Re: handling events between webpages..
    ... Iframe structure, as I've mentioned before, we'll have to utilize ... clientside script to do cross frame communication.... ... Microsoft Online Support ... |>> control on the page in serverside code. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Directing hyperlinks to a different frame, not page
    ... he did use Framesets and not iframes. ... I'm hoping he redoes his pages (preferably using an iframe instead). ... |>> link provided from a search and ends up with the loose frame with no ... |> | Because there's no link on your page, the bots cannot spider it. ...
    (microsoft.public.publisher.webdesign)
  • RE: Visio generated web page links open at top level and not in fr
    ... I use it as a halfway house solution. ... Also tried using the "Frame" option in the ShapeSheet options. ... Also tried iFrame options. ... If I link to a normal page (rather than the visio webfile) inside the iframe ...
    (microsoft.public.visio.general)