开发者

Reloading a tree navigation iframe from container page and from content iframe

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.

  1. Are there other issues 开发者_开发百科that I had not thought about?
  2. Is caching an issue?
  3. How do I prevent caching for the tree navigation iframe?

Thanks.


Caching seemed to be the problem. Adding this to the iframe page header fixed the problem.

<meta http-Equiv="Cache-Control" Content="no-cache">
<meta http-Equiv="Pragma" Content="no-cache">
<meta http-Equiv="Expires" Content="0">

Googled and found that answer here http://www.webdeveloper.com/forum/showthread.php?t=64667

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜