homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

JScript loaded in head writes to document body
is it possible?

10+ Year Member

Msg#: 139 posted 7:57 am on Jun 20, 2002 (gmt 0)

Ok im having this script that writes a specific DIV into the HTML. Normally when i wanted the script to write into the BODY of a document i would load it at the specific place in the BODY itself. But regarding the fact the i have to REPLACE an existing script by the new one, so that the new one is loaded instead of the old one, it would be toooooo much work to edit all existing HTML files of ALL existing projects (where the script is always loaded in the head). Thus i only have the chance to load the script in the head and somehow write the DIV layer to the BODY.

Shoot your ideas please.



10+ Year Member

Msg#: 139 posted 8:08 am on Jun 20, 2002 (gmt 0)

<script language="JavaScript" src="data.js" type="text/javascript"></script>
<div id="jsTarget"></div>


document.all.jsTarget.innerHTML = "whatever goes here";


10+ Year Member

Msg#: 139 posted 9:54 am on Jun 20, 2002 (gmt 0)

PsychoTekk's solution will generate a runtime error in Netscape 4.

I'd take the general idea of using an external .js file, but I would put the document.write() statements in a function:

function writeDiv(){

Then, in the HTML file itself, you need to write:


However, this unreliable to say the least. A far more workable solution would be to use a client-side script.

Andrew Revvo

10+ Year Member

Msg#: 139 posted 9:44 am on Jun 23, 2002 (gmt 0)

Stue: It is posible, but your head code must know that your web page is fully loaded.
I use flags and place them to the BODY code like:

<script language="JavaScript"> IsLoaded = 1;</script>

We used this technique on the our web site for a main menu layer changing. <snip>

[edited by: papabaer at 12:18 pm (utc) on June 23, 2002]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved