or*****@gmail.com wrote:
I am trying to override document.write, because there are cases in which
a slow response from a <script src=...request which produces
document.write calls is received after the page has finished loading. In
that case, it overwrites the entire page (as document.write does when the
page parsing is over).
Chances are that you have not properly analyzed the problem, and therefore
you jumped to conclusions as to its cause(s).
I am trying to use Resig's htmlparser for this mission (http://
ejohn.org/blog/pure-javascript-html-parser/), doing HTMLtoDOM instead of
the write.
Bad Idea, given Resig's lack of experience in this field. (And that's a
polite way of putting it.)
However, I need to inject the new DOM object in the correct position in
the tree, and that's where the document.write was called.
Is there a way to tell where in the DOM the document.write is located
when it's called?
Since the `script' element that is required to include the statement has to
be parsed first, the new element(s) would be inserted in the DOM tree after
that `script' element. That is what can be observed with Firebug in Firefox.
I need to know this in the scope of the overriding:
<code>
This is not a bulletin board, such confusing pseudo-tags are unwished for.
document.write = function(text) { HTMLtoDOM(text,callPosition); };
</code>
An even worse idea, attempting to overwrite host object's methods that are
more likely to be read-only.
How do I figure out callPosition?
Wrong question, and you can't, there.
If document.write() does not work for you (which I doubt), use DOM creator
and mutator methods to insert elements into the tree instead. Use DOM
retrieval methods to get the necessary context references.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>