473,660 Members | 2,437 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.docume nt.getElementBy Id( "here );
var tr = mywindow.docume nt.createElemen t( "tr" );
var td = mywindow.docume nt.createElemen t( "td" );

var txt = mywindow.docume nt.createTextNo de( 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 1369
In article <bt**********@o nline.de>, us**@domain.inv alid 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.dis play;
tblEl.style.dis play = "none";
....
// Restore the table's display style.
tblEl.style.dis play = 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.inv alid! 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>TESTWIND OW</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=fa lse, resizable=true, scrollbars=true ,"
+ "status=fal se, toolbar=false" );
}

var here = mywindow.docume nt.getElementBy Id( "here" );

var tr = mywindow.docume nt.createElemen t( "tr" );
var td = mywindow.docume nt.createElemen t( "td" );
var txt = mywindow.docume nt.createTextNo de( "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**********@o nline.de>, en********@REMO VETHISyahoo.de
enlightened us with...
Hi! I am us**@domain.inv alid! 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.docume nt 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.docume nt, 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
2410
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 narrowed it down to the Scrubber.py file.. If this seems like a quick step me through, I would be very appreciative, could get you something on your Amazon wish-list (that is me on my knees begging).. From just my basic understanding, it...
4
8360
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 document.theform, but not document.thelink i can use both this.theform and this.thelink and self.theform and self.thelink.
6
4990
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 + '"></TD>" ); How can I programmatically modify the contents of the cell whose name is held within m_UniqueCellName? The variable will get passed around to other functions, but try as I might,
5
6186
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 = self.opener.document.getElementById("A_Table"); myTR = self.opener.document.createElement("TR"); myTD=self.opener.document.createElement("TD");
1
1317
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 = self.opener.document.getElementById("MY_TABLE"); var row = myTable.insertRow(); var cell = row.insertCell(); cell.innerText = "New value";
1
6073
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 not appear (be deleted)---all the while, the window should resize if necessary. If you have a simpler example, that is fine. I just need a hint as to how you dynamically change the widgets and their layouts. Looking at the wx demos, there is...
64
6048
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 find, and now *sometimes* if you refresh the page (generally while it is still loading) in IE7, we get the popup window error: Internet Explorer cannot open the Internet site... Operation aborted
5
2103
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 display changes fine. But if I add or remove a table from any one of them, strange things happen. For example: start with a fresh copy of the downloaded database. Open the form and click on the "Admin" view. Right click and click on "Show Table"...
3
2302
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
8851
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...
0
8754
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8542
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,...
1
6181
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
5650
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
4177
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...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
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
1984
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.