What's the best way to reload a tree navigation iframe from within the HTML page containing that tree and from within the content area iframe?
The tree navigation iframe is defined in favorites.php (HTML page) like this.
<iframe id="tnav" src="loadtreeb.php" style="border: 0px; width: 200px; height: 86%; overflow: auto;">
</iframe>
If nodes are added to the tree, there is a button in the HTML page to save the updates by calling savepages.php. That php file is loaded into the content iframe.
<FORM name="pagesform" action="savepages.php" method="post">
<P style="font:12px Arial, Verdana;" >
Add one line for each page in this format: Page Name, Folder Name, http://thepage.com <br/>
<textarea name="newpages" rows="23" style="width:780px;"></textarea> <br/>
<input type="submit" value="Save Page(s)" style="margin-top: 5px;"/>
</P>
</FORM>
I reload the tree from within savepages.php (content iframe) like this.
<script type="text/javascript">
$(document).ready(function() {
$('#tnav', window.parent.document).attr('src','loadtreeb.php');
});
</script>
There are other actions performed from the HTML page that also reload the iframe from javascript. Here is one situation, a delete item button which calls a javascript function defined in the page script.
<div id="update">
<img src="treeico/delete.gif" style="cursor: pointer;" title="Delete" onclick="deleteitem();" />
</div>
function deleteitem()
{
//perform delete action
//reload tree
$('#tnav').attr('src','loadtreeb.php');
}
Neither call to .attr('src','loadtreeb.php') reloads the tree navigation, not
$('#tnav', window.parent.document).attr('src','loadtreeb.php')
,
and not
$('#tnav').attr('src','loadtreeb.php')
.
There must be an issue with getting to the #tnav. What could be the problem? I thought that adding the location window.parent.document
to locate #tnav was the right way to reload the tree navigation from within the content area iframe. Whereas omitting the location was the right way to reload from within the HTML page script.
- Are there other issues that I had not thought about?
- Is caching an issue?
- How do I prevent caching for the tree navigation iframe?
Thanks.