Re: document.write call position



orensol@xxxxxxxxx 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, <f806at$ail$1$8300dec7@xxxxxxxxxxxxxxxx>
.



Relevant Pages

  • Re: Dynamic select lists using optgroups again - without frameworks
    ... You will observe that you also don't need any DOM branching for this. ... For separation, you need to include one or more `script' elements in the ... Prototype.js was written by people who don't know javascript for people ...
    (comp.lang.javascript)
  • Re: how to call external .js file from another .js file
    ... while wondering why Javascript didn't have this functionality, ... namespacing, importing, and dynamic script loading support and works ... on all of today's major browsers plus many older ones like IE 4, ... which itself exists in the DOM. ...
    (comp.lang.javascript)
  • Re: how to call external .js file from another .js file
    ... functions for Javascript, if only for the sake of maintainable ... work it into the DOM from within the script, ... someFunction(), would I be able to call someFunctionin the ...
    (comp.lang.javascript)
  • VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
    ... Job is to convert that JAVASCRIPT code into SIMPLE VBA code ... Here's a bookmarklet that will tell you whether or not the browser ... JS sends request to the server (to a PHP script) ... This is the PHP script. ...
    (microsoft.public.vb.controls.internet)
  • VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
    ... Job is to convert that JAVASCRIPT code into SIMPLE VBA code ... Here's a bookmarklet that will tell you whether or not the browser ... JS sends request to the server (to a PHP script) ... This is the PHP script. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)