JavaScript document.write within a Frame

The Warden's picture

He has: 9 posts

Joined: Sep 2002

Hi. I have a situation where I'm unfortunately using frames. Now I want to use JavaScript, document.write to output a value within a frame. The problem is every time document.write is executed the entire frame is overwritten and just contains the value. Correct me here if I'm wrong but it is possible to document.write in a frame without the whole document been over written?

Here's a basic example of what I'm doing. Any help would be greatly appreciated!

index.html
Venmar's Intranet

Your browser doesn't support frames. Please upgrade your browser to current release.

navbar.html
hello

body.html
hello

<script LANGUAGE="JavaScript" TTYPE="text/javascript">
function fnTest()
{
document.write("hello world");
}
</script>

nicora's picture

He has: 267 posts

Joined: Nov 2001

Venmar's Intranet

Your browser doesn't support frames. Please upgrade your browser to current release.

Navbar.html

<script language="JavaScript1.2" type="text/javascript"></script>

hello

Body.html

<script language="JavaScript1.2" type="text/javascript"></script>

dk01's picture

He has: 516 posts

Joined: Mar 2002

The document.write function does not write inside a frame or a page after the page has been loaded. Instead you must use something called innerHTML or innerText. Here is a little link to explain it:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20542076.html

Don't forget that when using frames you have to refer to it with:
top.WindowNameHere.form
instead of
document.form
-dk

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.