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("cartTable")
>>
>>what is exactly this 'winDVDCart' ?
>>if a name of frame (or iframe) :
>>
>>cartTable=parent.winDVDCart.document.getElementById("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
Received on Tue Oct 18 02:58:34 2005