[thelist] Javascript question....

Alexander C. Garcia Alexander at Garcia.Name
Tue Jun 17 15:30:43 CDT 2003


Greetings everyone

  Before I begin I must re-iterate that I am a JavaScript newbie, now for my
little dilemma....

  I'm in the midst of publishing a DHTML website, that uses the JavaScript
innerHTML method to dynamically display text, images, etc. that are
requested through a link. I've gotten it to work fine, but when I try to
call the sub routine (function) that is nested 2 pages down it breaks.

For example this works fine:

Main Page >> (click on link) >> dynamic page loads.

But if I click on a link from the dynamically created page, it breaks using
the same method.
For example:

Main page >> (click on link) >> dynamic page loads >> (click on another
link) >> *breaks*
This is the code I use in an external JavaScript file (borrowed from
NetDev);

<code>

/*
 * Data Binder
 */

function iframeCallback(doc, tag) {
  myData = doc.getElementById(tag);
  try {
    textDiv.removeChild(textDiv.firstChild);
    textDiv.innerHTML = myData.innerHTML;
  }
  catch(e) {
    alert("ERROR: " + e);
  }
}

</code>

The code that calls the function gives it a 'document' object from that
page, along with the division id so it knows what to extract. Here's the
code..

<code>

<body onload="top.iframeCallback(document, 'clubs');">

</code>

I assume that the reason the nested page doesn't work is because the
'top.iframeCallback" is referring to the page that contains the link,
instead of the main page which actually contains the link to the function.
At least that's what I can derive form the error's I'm receiving in Opera.

Assuming I'm write what the best way to reference the 'original' or 'main'
page since 'top' only refers to the parent. I need some hierarchy object
reference, which references the original 'main' page. I hope this doesn't
sound like gibberish, if you need more code I can post.

Thank you very much.


Peace be with you.

Alexander Garcia
Alexander at Garcia.Name




More information about the thelist mailing list