473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

content added to DIV at runtime: timing

When content is transferred from a hidden IFRAME (which has fetched data
from a database) to a DIV in the main document, how can a script determine
that the DIV has been completely populated before it acts upon the data?

if (myIFRAME.document.readyState=='complete')
myDIV.insertAdjacentHTML("afterBegin",
myIFRAME.window.document.getElementById('data') )
// ...
// convert text in myDIV to uppercase
// code here may execute before action in line above completes, right?
Thanks
Timo

Jul 23 '05 #1
2 2441


Timo wrote:
When content is transferred from a hidden IFRAME (which has fetched data
from a database) to a DIV in the main document, how can a script determine
that the DIV has been completely populated before it acts upon the data?

if (myIFRAME.document.readyState=='complete')
myDIV.insertAdjacentHTML("afterBegin",
myIFRAME.window.document.getElementById('data') )
// ...
// convert text in myDIV to uppercase
// code here may execute before action in line above completes, right?


I don't see why it would makes sense to insert a HTML element with
insertAdjacentHTML so I guess if the element with id data is a form
control you want

myDIV.insertAdjacentHTML("afterBegin",
myIFRAME.window.document.getElementById('data').va lue)

or if it is a HTML container element you want

myDIV.insertAdjacentHTML("afterBegin",
myIFRAME.window.document.getElementById('data').in nerHTML);

but I don't see a timing problem, document manipulation happens
synchronously as long as you do not insert elements which load external
resources.

However you whole scripting seems to be geared towards the IE object
model as insertAdjacentHTML is not part of the W3C DOM so consider to
change to the W3C DOM if you want to build a page working with as many
of the modern browsers as possible.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
Martin,
Thanks for taking time to reply. I'll share more detail about the scenario.
zzzzz....

I'm building a treeview-like navigation interface, where the childnodes are
<A> elements.Each parent node in the tree has an empty DIV to hold its
childen. The tree is only two levels deep. The first major challenge is that
dataset that populates the treeview is so large that it cannot be downloaded
all at once for performance/latency reasons; so data are retrieved in
pieces, only as needed, upon node-expand. Only the first level is built upon
page load.

The data are fetched from the database via a hidden IFRAME conduit (instead
of XMLHTTP) and then, when the IFRAME's document has loaded (setTimeout,
readyState==complete) the contents of a DIV on the hidden IFRAME are moved,
as one block of html in one fell swoop into an empty DIV in the main page.
Each parent node has such a DIV for its child nodes. When the node is
collapsed the DIV is made invisible.

A second perhaps insurmountable challenge is that the customer wants the
treeview to be stateful without using postbacks. My choices, as I see them,
are to write back to the database via another hidden IFRAME or via XMLHTTP,
or to use cookies. Any other way to maintain state without using postback?
Remoting maybe. But for me, remoting is like The Paths of the Dead in LOTR.
I'll take that route last.

At the moment, I'm trying the cookie approach. The customer wants the
treeview to look exactly as it was -- all previously opened nodes still open
and populated-- when the user returns to the page after visiting another.
So, upon node-expand, I'm storing each DIV's worth of childnodes retrieved
from the database in a separate session cookie; each populated DIV has its
own cookie which contains the DIV's innerHTML. When the treeview page is
loaded, I read those cookies and repopulate each childnode DIVs in my
OpenNodesList (also stored as a cookie).

Problem: my code works in the IE debugger but often not at runtime.
Sometimes the DIVS do not get repopulated. So I'm assuming there's a timing
issue between reading the cookie and writing to the DIV. Sometimes the
cookie might contain 20K. I'm in a tight loop reading cookies and with each
iteration inserting a block of HTML into the target DIV:

PSEUDOCODE:

for each node in OpenNodesList
// myData contains a series of <A> elements
// DIV is empty before the insert
myData = GetCookie(node)
getDIV(node).insertAdjacentHTML = myData

I'll find the non-proprietary way to insert the HTML into the target DIV
after I've proved (or disproved) the viability of the concept in IE. But is
the above loop actually feasible? GetCookie would also have to be
synchronous, right?
Timo

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:40********@olaf.komtel.net...
:
:
: : I don't see why it would makes sense to insert a HTML element with
: insertAdjacentHTML so I guess if the element with id data is a form
: control you want
:
: myDIV.insertAdjacentHTML("afterBegin",
: myIFRAME.window.document.getElementById('data').va lue)
:
: or if it is a HTML container element you want
:
: myDIV.insertAdjacentHTML("afterBegin",
: myIFRAME.window.document.getElementById('data').in nerHTML);
:
: but I don't see a timing problem, document manipulation happens
: synchronously as long as you do not insert elements which load external
: resources.
:
: However you whole scripting seems to be geared towards the IE object
: model as insertAdjacentHTML is not part of the W3C DOM so consider to
: change to the W3C DOM if you want to build a page working with as many
: of the modern browsers as possible.
:
: --
:
: Martin Honnen
: http://JavaScript.FAQTs.com/
:
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a...
10
by: Greg Stark | last post by:
This query is odd, it seems to be taking over a second according to my log_duration logs and according to psql's \timing numbers. However explain analyze says it's running in about a third of a...
6
by: Angus Comber | last post by:
Hello I am testing and think I have a timing issue. On Windows I used sleep function to wait a while. Is there a C Runtime equivalent? I need to port some code to Linux. Angus
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
1
by: Anders K. Jacobsen [DK] | last post by:
Hi im creating a (or is starting but need your advise) search page for some products which has surdden charataristicas which all should be serachable. These charataristicas can be added runtime so...
2
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no...
7
by: Electric Co. | last post by:
Hello, note: This is for a Faculty web site that is undergoing a migration to an open source solution so my motives are legit. I need to build a relay from IIS handling URL_A to a PHP server...
13
by: =?Utf-8?B?S2VzdGZpZWxk?= | last post by:
Hi Our company has a .Net web service that, when called via asp.net web pages across our network works 100%! The problem is that when we try and call the web service from a remote machine, one...
6
by: rn5a | last post by:
The different Page events in the page life cycle like Page_PreInit, Page_Init, Page_Load etc. - are they different stages of the runtime process? Does a server send back the HTML output of an...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.