473,804 Members | 3,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.getEle mentById("***") .contentDocumen t

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="Compositi on" ID="Composition ">
</IFRAME>
<SCRIPT LANGUAGE="JavaS cript1.2">
<!--
var scrollwindow = document.getEle mentById("Compo sition").conten tDocument;
var page = "<P>hello</P>";
scrollwindow.bo dy.innerHTML = page;
//-->
</SCRIPT>
</BODY>
</HTML>

Thanks if advance for any help!
Eric
Jul 20 '05 #1
2 14301
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="Compositi on" 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="nameCompo sition"
id="idCompositi on">[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...A lt+P/Page style/Enable inline
frames.]</iframe>
<SCRIPT LANGUAGE="JavaS cript1.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.getEle mentById("Compo sition").conten tDocument;
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["Compositio n"].document.body. innerHTML =
"<P>hello</P>";

would work, should work.
var page = "<P>hello</P>";
scrollwindow.bo dy.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.getEle mentById("idIfr ame").contentDo cument[...].

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
8825
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
9278
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 work on FireFox or Netscape. What could be wrong? The function: function setActiveTab(tabNo) {
1
9192
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 an idea why this might be? Here is the entire function
2
6320
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 there than i can get value of that control by document.getelementbyid("header1_txtname").value this is works fine in the I.E 6 but the mozilla gives error for it in javascript console Error is like this: Error:...
6
4626
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
3824
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 reports the error in the console - "document.getElementById("image1") has no properties". Pls advice. thanks rupak <?xml version="1.0" encoding="UTF-8"?> <jsp:root version="1.2" ...> ...
4
70098
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; aForm.nav_page_name.value = pages.value]; var si = pageElement.selectedIndex;
2
2023
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); document.getElementById('namedisplay').value=name;
2
3140
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 and does work. I and others have experienced that it should & doesn't work. I'll give you a little file that I tested with IE 6, FF 3, Opera & Chrome. Only the form button, document.myname.submit(); and document.forms.submit(); worked. Take a...
0
10567
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10310
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4291
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 we have to send another system
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.