473,322 Members | 1,347 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,322 software developers and data experts.

[variable1] has no properties

I am getting a Javascript error from Firefox 1.0.5 when I try to reference a
table within a window that has just been opened and written to. I get the
Javascript error "cartTable has no properties" where cartTable is the
variable I assigned the table reference to.

cartTable=winDVDCart.document.getElementById("cart Table")

Previous to this, I have just opened a new window, used the document.write
method to write some HTML into it, and then used the document.close method.
At that point I call a new function to add some extra things into the new
window and this is the first statement that gets run. It seems as if the
table isn't quite finished loading when I try to reference it and that is
causing problems. I am not getting any errors in IE6 and it is working just
fine. I figured that maybe I could implement a loop to just wait until the
table is fully loaded but that will just loop infinitely for some odd
reason.

while (!winDVDCart.document.getElementById("cartTable")) {}

This code just loops infinitely, but if I just put an alert within the {}
for the while loop, it shows the alert once, I click ok and everything works
great after that. Could anyone point me in the right direction on this?

Thanks,

David
Jul 23 '05 #1
5 2109
ASM
David wrote:
I am getting a Javascript error from Firefox 1.0.5 when I try to reference a
table within a window that has just been opened and written to. I get the
Javascript error "cartTable has no properties" where cartTable is the
variable I assigned the table reference to.

cartTable=winDVDCart.document.getElementById("cart Table")
what is exactly this 'winDVDCart' ?
if a name of frame (or iframe) :

cartTable=parent.winDVDCart.document.getElementByI d("cartTable")

if self main window name :
cartTable=document.getElementById("cartTable")

while (!winDVDCart.document.getElementById("cartTable")) {}


probably if you insert your JS and its code
after </table> the 1st way would run.
--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #2
ASM Wrote:
David wrote:
I am getting a Javascript error from Firefox 1.0.5 when I try to
reference a table within a window that has just been opened and written
to. I get the Javascript error "cartTable has no properties" where
cartTable is the variable I assigned the table reference to.

cartTable=winDVDCart.document.getElementById("cart Table")


what is exactly this 'winDVDCart' ?
if a name of frame (or iframe) :

cartTable=parent.winDVDCart.document.getElementByI d("cartTable")

if self main window name :
cartTable=document.getElementById("cartTable")


winDVDCart is the handle to the window that was opened
while (!winDVDCart.document.getElementById("cartTable")) {}


probably if you insert your JS and its code
after </table> the 1st way would run.


This is not possible unless I insert a call to this function from a <script>
tag that is located after the </table>. This is all dynamic and thus part
of a big long string that gets written to the window when it is open.
Without explaining all the details, I'll suffice it to say that this is not
a desirable way of doing, though it is possible, it is a method I would
prefer to save as a last resort.

Any other ideas?
Jul 23 '05 #3
David said the following on 7/19/2005 9:52 PM:
ASM Wrote:
David wrote:

<--snip-->
This is not possible unless I insert a call to this function from a <script>
tag that is located after the </table>. This is all dynamic and thus part
of a big long string that gets written to the window when it is open.
Without explaining all the details, I'll suffice it to say that this is not
a desirable way of doing, though it is possible, it is a method I would
prefer to save as a last resort.

Any other ideas?


Set an onload event handler for the new window:

winDVDCart.onload = functionToCall;

And have functionToCall be the continuation function where it gets a
reference to the table.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #4
David wrote:
ASM Wrote:
David wrote:
I am getting a Javascript error from Firefox 1.0.5 when I try to
reference a table within a window that has just been opened and written
to. I get the Javascript error "cartTable has no properties" where
cartTable is the variable I assigned the table reference to.

cartTable=winDVDCart.document.getElementById("c artTable")


what is exactly this 'winDVDCart' ?
if a name of frame (or iframe) :

cartTable=parent.winDVDCart.document.getElementB yId("cartTable")

if self main window name :
cartTable=document.getElementById("cartTable")

winDVDCart is the handle to the window that was opened

while (!winDVDCart.document.getElementById("cartTable")) {}


probably if you insert your JS and its code
after </table> the 1st way would run.

This is not possible unless I insert a call to this function from a <script>
tag that is located after the </table>. This is all dynamic and thus part
of a big long string that gets written to the window when it is open.
Without explaining all the details, I'll suffice it to say that this is not
a desirable way of doing, though it is possible, it is a method I would
prefer to save as a last resort.

Any other ideas?


You could use setTimeout to call the remainder of your function. That
should enable enough of a delay to allow the table to be accessed.

function openWindow(...){
winDVDCart = window.open(...);
winDVDCart.document.write( ... )
...
winDVDCart.document.close();

setTimeout( function () {
// do whatever
}, 10 );
}

Or you could put the rest of the script into a different function and
call that, either directly or with setTimeout (be careful with closures).

--
Rob
Jul 23 '05 #5
Randy Webb wrote:

Set an onload event handler for the new window:

winDVDCart.onload = functionToCall;

And have functionToCall be the continuation function where it gets a
reference to the table.


Well this seems to work fine in both browsers now, definitely not how I'd
like to do it, but I guess it works. Thanks for the help, and as for the:

winDVDCart.onload = functionToCall;

see my post in this group under the name "Adding events dynamically". It
appears that Firefox 1.0.5 doesn't like this syntax and will only call the
function if you put parentheses after it as in

winDVDCart.onload = functionToCall();

which is definitely not correct syntax and should do something totally
different. Anyway, just thought I'd add that on a side note.

Thanks again,

David
Jul 23 '05 #6

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

Similar topics

8
by: Paul | last post by:
Hello, I've been reading up on security in Java Applets and whilst I understand the concept, I can't successfully get my applet to read a file on my local machine. I discovered from...
2
by: Rick Austin | last post by:
I recently had to perform a reinstalltion of Windows XP (my registry seems to have become corrupt). After this completed I had to reinstall all applications since most use the registry for settings,...
9
by: kj | last post by:
Is there any way to programmatically discover and inspect *all* the properties of an object, even those that are not enumerable through a for/in loop? Thanks! kj -- NOTE: In my address...
4
by: Lyn | last post by:
Hi, This question may seem a bit academic... To learn more about Access VBA, I have been enumerating the properties of various form controls. This was mostly successful and I have learned a lot...
10
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a...
1
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled...
7
by: Anderskj | last post by:
Hi! I am developing a c# application. I have a interface (which can change therefore my problem) If i do like this: List<PropertyInfoproperties = new List<PropertyInfo>();...
0
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to...
4
by: FullBandwidth | last post by:
I have been perusing various blogs and MSDN pages discussing the use of event properties and the EventHandlerList class. I don't believe there's anything special about the EventHandlerList class in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.