473,396 Members | 1,809 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,396 software developers and data experts.

'document is not an object' when trying to change <DIV> content

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 of the screen that initially
comes up with a gif image of a house:

<!-- start "house" layer definition for center of screen -->
<DIV id="house" style="position:absolute; left:140px; top:137px;
width:510px; height:325px; z-index:2"><img src="images/house.gif"
width="510" height="325"></DIV>
<!-- end "house" layer definition -->

In another portion of the browser I have a navigation bar built in
another <DIV> layer that includes a number of links:

<!-- start "rtnav" layer definition for lower right navigation links
-->
<DIV id="rtnav" style="position:absolute; left:600px; top:400px;
width:200px; height:100px; z-index:13">
<SPAN id="members" class="rightnav"><a href="javascript:void();"
onClick="gotoMembers();">Member Login</a></SPAN>
</DIV>
<!-- end "rtnav" layer definition -->

In the <HEAD> portion, I have a <SCRIPT> section that includes the
function gotoMembers() {} that I am hoping can either use
document.write('...'); or perhaps a load("members.htm",800);
{preferred} to change the existing content (the gif of a house) to a
small login form:

function gotoMembers() { // pop up member dialog in blueCenter
// Example is being tested in Internet Explorer. I have also used
document.all["house"] and done
// similar testing in Netscape using document.layers["house"] without
success.

// - try using 'load' method to load an external page
// document.getElementById("house").load("members.htm ",800);

// - using document.write('...');
document.getElementById("house").document.open();
document.getElementById("house").document.write('t his is a test, this
is only a test - please work!!!');
document.getElementById("house").document.close();
}

Whenever I use the 'document.method();' it says "{node}.document is
not an object" where {node} is the method I used to retrieve the DIV
layer ID. I have confirmed that I can use all three constructs to
change the style.visibility='hidden' so it's not something else
somewhere and I have tried this in both Netscape 7.1 and Internet
Explorer Version: 6.0.2800.1106

What am I missing here?

As stated, my preference would be to load a seperate .htm file
including mark-up into the target frame "house" but none of the
document properties appear to be defined for that layer. Any help
would be appreciated.

Kathy
Jul 20 '05 #1
3 9811

"Catherine Lynn Smith" <kl*****@hotmail.com> schreef in bericht
news:5f**************************@posting.google.c om...

function gotoMembers() { // pop up member dialog in blueCenter
// Example is being tested in Internet Explorer. I have also used
document.all["house"] and done
// similar testing in Netscape using document.layers["house"] without
success.

// - try using 'load' method to load an external page
// document.getElementById("house").load("members.htm ",800);

// - using document.write('...');


document.write can only be used with <layers /> in Netscape 4 when the page
is already loaded. document.getElementById(...).load(...) won't work either.

You could use an iframe instead voor Netscape 7/Mozilla and IE if you want
to include content URL based, but if you want to write to the div, you
should use its innerHTML property:

IE 4:
document.all['divID'].innerHTML = stringHTML;

IE 5+/Mozilla/Netscape 7+/Opera 7:
document.getElementById('divID').innerHTML = stringHTML;
JW

Jul 20 '05 #2


In have understood well (I hope!), you'd like to change the content
of a tag div (an img) clicking another div, look if this is suitable for
you, using DOM:
<html>
<head><title>Try</title>
<script>
function change() {
var div = document.getElementById("firstDiv");
var old = div.childNodes[0];
var xxx = document.createElement("form");
var son = document.createElement("input");
div.replaceChild(xxx, old);
div.childNodes[0].appendChild(son).setAttribute("type", "text");
}
</script>
</head>
<body>
<div id="firstDiv"><img id="whatever" src="fotografie.jpg" /></div>
<div id="another"onClick="change();">clickme!</div>
</body>

hope it could help you!!!

ciao

g. paolini
Jul 20 '05 #3
OK - I will try that - also, is there a way to do this by retreiving
the new content from another stand-alone html file? (e.g.
"members.htm")

KL

son3mendo <son3mendo@_NS_excite.it> wrote in message news:<pan.2003.09.11.21.13.33.419877@_NS_excite.it >...
In have understood well (I hope!), you'd like to change the content
of a tag div (an img) clicking another div, look if this is suitable for
you, using DOM:
<html>
<head><title>Try</title>
<script>
function change() {
var div = document.getElementById("firstDiv");
var old = div.childNodes[0];
var xxx = document.createElement("form");
var son = document.createElement("input");
div.replaceChild(xxx, old);
div.childNodes[0].appendChild(son).setAttribute("type", "text");
}
</script>
</head>
<body>
<div id="firstDiv"><img id="whatever" src="fotografie.jpg" /></div>
<div id="another"onClick="change();">clickme!</div>
</body>

hope it could help you!!!

ciao

g. paolini

Jul 20 '05 #4

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

Similar topics

18
by: Timothy Casey | last post by:
Thanks in advance... =~= Timothy Casey South Australia worloq@iprimus.com.au Formerly: casey@smart.net.au
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
4
by: He Shiming | last post by:
Hi, I'm wondering how can I use <DIV> to mimic a <TABLE>. In a bare <TABLE> without a width attribute, the width of the table get dynamically expanded according to the content. However, <DIV>...
2
by: vidyasada | last post by:
Hi i m new to javascript . i need a script to srcoll the <div> content vertically within the <div> and it stops few seconds at the end of the content .. and again starts scrolling.. please...
28
by: Kent Feiler | last post by:
1. Here's some html from a W3C recommendations page. <P>aaaaaaaaa<DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</DIV> 2.Although I didn't think it would make any difference, I tried it with the...
4
by: ontheplains | last post by:
so i need to use a mouseOver on a piece of text that is in one <div> (says "Show Me the Alternate") to make a <div> tag that has content in it move from its current spot (left: 20%), to out of the...
5
by: chakradhari.ashish | last post by:
Does anybody know how can I load an html page inside a <div</div> where the content gets update on the onclick even of anchor <a href=> </a>? I googled around and followed some links pointing me...
10
by: Summercoolness | last post by:
so i am starting to use more of <br /and <div style="clear: both" / which is the XHTML style... now, won't those actually confuse the old browsers? for example, will the old browser treat the...
6
goatboy
by: goatboy | last post by:
So I am hosting a site from my home server, and I would like the main page to be an area for updates about the site. I am providing these updates in a blog-style format, using this code: ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.