473,508 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot modify a table in a self created window

I created a window with

var mywindow = window.open( "some/local.html", "mywindow", "width=...,
"height=...., ..." );

The window shows up. It contains a table.

<table>
<tr>
<td>begin</td>
</tr>
<tr id="here">
<td>end</td>
</tr>
</table>

Trying to modify the table (with the following code) fails using Mozilla
1.5 (IE6 works):

var here = mywindow.document.getElementById( "here );
var tr = mywindow.document.createElement( "tr" );
var td = mywindow.document.createElement( "td" );

var txt = mywindow.document.createTextNode( strType );

td.appendChild( txt );
tr.appendChild( td );

here.parentNode.insertBefore( tr, here );

alert( here.parentNode.innerHTML ); show that the new node exists.

But when executing this in Mozilla the new table row is not displayed.


Jul 20 '05 #1
3 1356
In article <bt**********@online.de>, us**@domain.invalid enlightened us
with...
I created a window with

var mywindow = window.open( "some/local.html", "mywindow", "width=...,
"height=...., ..." );

The window shows up. It contains a table.
When making dynamic tables, use thead, tbody, and tfoot as appropriate.
It made things easier for me and new scripts that use them are easier to
use with your tables.

<table> <tbody> <tr>
<td>begin</td>
</tr>
<tr id="here">
<td>end</td>
</tr> </tbody> </table>

Trying to modify the table (with the following code) fails using Mozilla
1.5 (IE6 works):
But when executing this in Mozilla the new table row is not displayed.


A script I downloaded had a comment in it about NN/MOZ and visibility
when a table was being sorted dynamically...

// Set the table display style to "none" - necessary for Netscape 6
// browsers.
var oldDsply = tblEl.style.display;
tblEl.style.display = "none";
....
// Restore the table's display style.
tblEl.style.display = oldDsply;

Maybe that will help?

--
--
~kaeli~
Those who jump off a bridge in Paris... are in Seine.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
Hi! I am us**@domain.invalid! Forgot to configure my news settings. Sorry!

I isolated the problem (see sample source code at end).
The funny thing is, that adding a line to the table works now.
But.... if the window is created (first call of test()) then the element
"here" can not be found. This seems to be a timing problem. Window not
completed yet? How can I synchronize this?

Greetings,
dp

-- begin: testwindow.html --
<html>
<head>
<title>TESTWINDOW</title>
<script>
var mywindow = null;
function test() {

if( null == mywindow ) {
mywindow = window.open( "local.html", "aName",
"width=400, height=400, left=10, top=10, location=false,"
+ "menubar=false, resizable=true, scrollbars=true,"
+ "status=false, toolbar=false" );
}

var here = mywindow.document.getElementById( "here" );

var tr = mywindow.document.createElement( "tr" );
var td = mywindow.document.createElement( "td" );
var txt = mywindow.document.createTextNode( "text" );

td.appendChild( txt );
tr.appendChild( td );

if( null != here ) {
here.parentNode.insertBefore( tr, here );
}
}
</script>
</head>
<body>
<table border="1">
<tr>
<td onclick="test(); return false;">test</td>
</tr>
</table>
</body>
</html>
-- end: testwindow.html --

-- begin: local.html --

<html>
<head>
<title>LOCAL</title>
<script>
</script>
</head>
<body>
<table>
<tr>
<td>begin</td>
</tr>
<tr id="here" >
<td>end</td>
</tr>
</table>
</body>
</html>

</html>
-- end: local.html --

Jul 20 '05 #3
In article <bt**********@online.de>, en********@REMOVETHISyahoo.de
enlightened us with...
Hi! I am us**@domain.invalid! Forgot to configure my news settings. Sorry!

I isolated the problem (see sample source code at end).
The funny thing is, that adding a line to the table works now.
But.... if the window is created (first call of test()) then the element
"here" can not be found. This seems to be a timing problem. Window not
completed yet? How can I synchronize this?

I would suggest setTimeout, but if people are using different connection
speeds, this could be variable.

I'd suggest a loop, waiting until mywindow.document is defined (not the
element itself, in case something goes wrong and the page is 404 or
something), but I think in the right situation, something could go very,
very wrong with that and you'd get an infinite loop.

So, my suggestion is a setTimeout at 1 second intervals that checks for
mywindow.document, loops if it isn't defined, but only loops 30 times.
No doc should take more than 30 seconds to load, unless it's the result
of a big DB operation or something.

Perhaps someone knows how to make it wait with an onload...or maybe
there is a .loaded property?

--
--
~kaeli~
Not one shred of evidence supports the notion that life is
serious.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4

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

Similar topics

0
2398
by: Chris McKeever | last post by:
I am trying to modify the Mailman Python code to stop mapping MIME-types and use the extension of the attachment instead. I am pretty much clueless as to what I need to do here, but I think I have...
4
8346
by: Wow | last post by:
when calling a object in an html, should I use self.objectname this.objectname or document.objectname? for example, i have a form called theform and a link called thelink i can call...
6
4976
by: Anon | last post by:
I have a table with a cell. The cell's ID is created using a unique name that is held in m_UniqueCellName and the cell is created like so... document.write( "<TD ID="' + m_UniqueCellName +...
5
6181
by: mike | last post by:
I am adding a row to a table from a child window that opened from the parent window. My js looks like: if ( self.opener.document.update ) { var rows =...
1
1309
by: Wescotte | last post by:
I'm having problems changing a table from a child window. What works (but I really want to add more complex objects to teh cells not just plain text) var myTable =...
1
6063
by: Grant | last post by:
Hi, I am looking for a tip. I have a panel and a checkbox. When I check the checkbox, I would like to add buttons to the panel (dynamically). When the checkbox is unchecked, the buttons should...
64
6001
by: Mika | last post by:
Hello, we understand you guys may be able to help. We have a page which has been working great for over a year and gets many hits. However recently something got changed that we cannot seem to...
5
2098
by: terrybell105 | last post by:
I downloaded Stephan's utility from his website but can't get it to work - or maybe I'm not driving it properly! The form works OK with the existing 3 "views" - I can switch between them and they...
3
2289
by: pinko1204 | last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx PHP1 <?php require_once 'header.php'; ?> <style type="text/css"> <!--
0
7124
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
7326
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,...
1
7046
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
7498
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
5629
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
4707
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...
0
3195
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
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.