473,396 Members | 2,029 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.

appendChild problem

Hi

I'm trying to spread a table across a frameset. So I have index.htm
that has an iframe sourcing the frameset. What I'm trying to do is
create a table in index.htm to spread across the whole brower window.

My code, ran from within the frameset:

function Createtbl(){
var tbl = document.createElement('table');

tbl.height = "100%";
tbl.style.height = "100%";
tbl.width = "100%";
tbl.style.width = "100%";

var newRow = tbl.insertRow(-1);
var newCell = newRow.insertCell(-1);
newCell.innerHTML = "hello world";

var holder = top.document.createElement('div');
top.document.appendChild(holder);

holder.outerHTML = tbl.outerHTML;

}

The above doesn't work, the below only works in ie

If in index.htm I create a div tag with the id "holder":-
function Createtbl(){
var tbl = document.createElement('table');

tbl.height = "100%";
tbl.style.height = "100%";
tbl.width = "100%";
tbl.style.width = "100%";

var newRow = tbl.insertRow(-1);
var newCell = newRow.insertCell(-1);
newCell.innerHTML = "hello world";

var holder = top.document.getElementById('holder');
holder.outerHTML = tbl.outerHTML;

}

Any ideas to get this to work in firefox? And create the "holder"
dynammically?

NB: creating the table can't be top.document.createElement as the code
the generate it is another function used for various things.

Cheers

Alex

Aug 23 '06 #1
2 1816
Forgot to mention that I set the table to absolute and zindex to 2 so
appears over the iframe.

Cheers

Alex

Aug 23 '06 #2
al*****@gmail.com wrote:
Hi

I'm trying to spread a table across a frameset. So I have index.htm
that has an iframe sourcing the frameset. What I'm trying to do is
create a table in index.htm to spread across the whole brower window.

My code, ran from within the frameset:

function Createtbl(){
var tbl = document.createElement('table');

tbl.height = "100%";
tbl.style.height = "100%";
tbl.width = "100%";
tbl.style.width = "100%";

var newRow = tbl.insertRow(-1);
var newCell = newRow.insertCell(-1);
newCell.innerHTML = "hello world";

var holder = top.document.createElement('div');
top.document.appendChild(holder);

holder.outerHTML = tbl.outerHTML;

}

The above doesn't work, the below only works in ie

If in index.htm I create a div tag with the id "holder":-
function Createtbl(){
var tbl = document.createElement('table');

tbl.height = "100%";
tbl.style.height = "100%";
tbl.width = "100%";
tbl.style.width = "100%";

var newRow = tbl.insertRow(-1);
var newCell = newRow.insertCell(-1);
newCell.innerHTML = "hello world";

var holder = top.document.getElementById('holder');
holder.outerHTML = tbl.outerHTML;

}

Any ideas to get this to work in firefox? And create the "holder"
dynammically?

NB: creating the table can't be top.document.createElement as the code
the generate it is another function used for various things.

Cheers

Alex
A few considerations:

1) The innerHTML / outerHTML attributes are not reliable. You should
avoid using them, if possible.

2) Even assuming that they are reliable in and of themselves, they are
certainly NOT reliable if the element does not even exist in the
document. You have created an orphaned node (the table element) and it
has not necessarily been assigned any markup.

3) You are creating elements in one document, and then trying to append
them to an element in another document. This is not reliable (and in
fact, should not work). In a DOM2-compliant browser, you should be able
to use importNode to create a copy of the node in the target document,
but IE is not such a browser and does not implement this function.

If you describe in more detail what your goal is, and why you are doing
it (what do you mean by "spread a table across a frameset", and why are
you doing this?), then the group may be more able to suggest proper
methods for accomplishing your goal.

Jeremy
Aug 23 '06 #3

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

Similar topics

3
by: Ray | last post by:
I have put together some pretty simple code for adding and removing elements from an XML file, but am having a problem with toxml writing out the correct format after I have called appendChild on a...
25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
1
by: Nicolas Van Lancker | last post by:
Hi folks; I have this webpage, allowing users to insert multiple records in one post into the database. Because I don't know the exact number of records they want to add, I created a little...
6
by: skubik | last post by:
Hi everyone. I'm attempting to write a Javascript that will create a form within a brand-new document in a specific frame of a frameset. The problem is that I can create the form and input...
1
by: Ryan Stewart | last post by:
If you don't want to read this post because of its length, I understand. I've spent two and a half days on this problem and have a good deal of information to relate. And this is kind of a long...
3
by: Robi | last post by:
I have the following code: ############## var nHead=(document.getElementsByTagName)?document.getElementsByTagName("head").item(0):document.head; var nStyle=document.createElement("style"); //...
7
by: Robert Oschler | last post by:
I'm having a very painful time converting some Mozilla dynamic DOM code to work with Internet Explore. For example, given this code: -------------- selectBox=document.createElement("SELECT");...
4
by: matty | last post by:
Hello, here is an example of what is driving me totally crazy. This example will show that the first call to "doit()" will print 30 times the image with only one call to the server. Then I have...
2
by: vsanjit | last post by:
Hi all, I've been trying to create a table dynamically upon the generation of en event using the appendChild method in Javascript. This seems to work fine in Firefox, but not in IE7. There's also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
0
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...

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.