473,472 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

document.getElementById("***").contentDocument

I'm having a problem with the following html (I've simplified it down
to a simple test case). Could anyone point out why Mozilla is having
problems with this (I've tried so many variations that I can't think
of any more). In the actual code I have an if statement to handle IE
but I need the code to work in Mozilla and IE.

<HTML>
<BODY>
<IFRAME width="100" height="100" NAME="Composition" ID="Composition">
</IFRAME>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
var scrollwindow = document.getElementById("Composition").contentDocu ment;
var page = "<P>hello</P>";
scrollwindow.body.innerHTML = page;
//-->
</SCRIPT>
</BODY>
</HTML>

Thanks if advance for any help!
Eric
Jul 20 '05 #1
2 14258
DU
Eric Pickup wrote:
I'm having a problem with the following html (I've simplified it down
to a simple test case). Could anyone point out why Mozilla is having
problems with this (I've tried so many variations that I can't think
of any more). In the actual code I have an if statement to handle IE
but I need the code to work in Mozilla and IE.

<HTML>
<BODY>
<IFRAME width="100" height="100" NAME="Composition" ID="Composition">
</IFRAME>
1- There is no src attribute and src attribute value for your iframe here.

2- I strongly suggest you always give different and distinct attribute
values to id and name for several reasons: it helps code readability,
code debugging with debuggers, code review by others. I personally use
prefixing in this manner:

<iframe width="100" height="100" name="nameComposition"
id="idComposition">[Your user agent does not seem to support iframes or
is currently configured not to display iframes. If you're using Opera
6+, you can with File/Preferences...Alt+P/Page style/Enable inline
frames.]</iframe>
<SCRIPT LANGUAGE="JavaScript1.2">
language is a deprecated attribute; type has superseded language and is
both backward and forward compatible. So,

<script type="text/javascript">
<!--
var scrollwindow = document.getElementById("Composition").contentDocu ment;
This is wrong. Your iframe Composition is an element of a page here.
To modify dynamically the content of your iframed document,
I'm almost 100% sure that

var scrollwindow = frames["Composition"].document.body.innerHTML =
"<P>hello</P>";

would work, should work.
var page = "<P>hello</P>";
scrollwindow.body.innerHTML = page;
//-->
</SCRIPT>
</BODY>
</HTML>

Thanks if advance for any help!
Eric


There is a much better way to do what you are attempting to do here.
Many months ago, I wrote a script just achieving what you want to do,
and it works extremely well for MSIE 6 for Windows, Mozilla-based
browsers (17 different browsers), Opera 7 and most likely other W3C web
standards compliant browsers. The code uses only valid W3C markup code,
valid css code and W3C DOM 2 properties and methods.

http://www10.brinkster.com/doctorunc.../MainPage.html

Opera 7 has a bug with disabling button while MSIE 6 for Windows has a
padding issue with iframes.
Don't bookmark the page as I'll probably tune and tweak again the page
and rename the page.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #2
DU

Ok. I remove the previous MainPage.html from my site.

http://www10.brinkster.com/doctorunc...ticIframe.html

is basically what you were trying to do. Because MSIE 6 does not support
contentDocument, it's preferable to avoid it and resort to another way
to reference the document: i.e.
frames["nameIframe"].document.[...]
which is more widely supported than
document.getElementById("idIframe").contentDocumen t[...].

http://www10.brinkster.com/doctorunc...micIframe.html

is another variant where you try to dynamically modify a document
(inserting Hello) which is loaded inside a dynamically created iframe.
You'll see that Opera 7.x and Mozilla-based browsers are much more
powerful than MSIE 6 for windows in this sort of scripts.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #3

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

Similar topics

7
by: Phin | last post by:
Hi, I am tring to update some text in a div statement via document.getElementById("test").innerHTML = "data loaded!" and <div id="test"> Loading ... please hold!
3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
1
by: gslim | last post by:
I am trying to implement the busybox sample from // From Mark Wagner // http://blogs.crsw.com/mark/articles/642.aspx When I get to this line I get an access denied error. Could someone give me...
2
by: yourmallu | last post by:
Hi Friends, All we are knowing that we can get the element by document.getelementbyid("default_txtname").value. But If it is not on that page if i am taking header.ascx and placing text box...
6
by: linuxnooby | last post by:
Hi I want a form field to be selected when the page loads. But I get the error message Error: document.getElementById("ff") has no properties any ideas what I am doing wrong? code below
3
by: rkhurana | last post by:
Hi I am writing a JSF application that uses some third party charts. While I can see the chart but the javascript that is supposed to calla function to update chart periodically has a problem. It...
4
by: gimme_this_gimme_that | last post by:
Hi, I have an onchange method for a select box that goes something like this (the select is in a form named aForm): function page_on_change() { pageElement = aForm.my_page_id;...
2
by: ratcateme | last post by:
I have this script function getname(){ <script type="text/javascript"> var name = prompt('What is your name?'); while(name==''){ name = prompt('We need your name?'); } alert(name);...
2
by: ChrisLA | last post by:
Hi; I've seen lots of discussion & disagreement on this issue, so any good explanation would be appreciated. Some people seem to think that "document.GetElementByID("MyName").submit(); should...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.