473,386 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,386 software developers and data experts.

document.write call position

Hello,

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

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. 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? I need to know this in the scope of the overriding:

<code>
document.write = function(text)
{
HTMLtoDOM(text,callPosition);
};
</code>

How do I figure out callPosition?

Oren
Sep 16 '08 #1
1 1836
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>
Sep 16 '08 #2

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

Similar topics

3
by: Catherine Lynn Smith | last post by:
I am creating a webpage with dhtml <DIV> layers and I want a link on one layer to modify the content on another but I seem to keep running into errors. Basically I create a layer in the middle...
10
by: Rithish | last post by:
I want to emulate paging in an HTML document. something like, ------------------------- | | | <DIV> | | | | <TABLE></TABLE>...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
8
by: geoffdude | last post by:
Hi everyone, newbie here. I'm really close to finishing my zip code search filter thingy to return a specific message (ultimately a unique phone number for sales contact) after a form query (of...
0
by: martinmercy2001 | last post by:
Could any body help me with creating a ring buffer class using a string. use memory circular buffer not an IO buffer. just read, write and seek method. Read method should take anumber and return the...
10
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I had a program and it always works fine and suddenly it gives me the following message when a pass a xml file to our server program: error code: -1072896680 reason: XML document must...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.