从容器页面和内容 iframe 重新加载树导航 iframe

发布于 2024-11-26 19:13:59 字数 1886 浏览 2 评论 0原文

从包含树的 HTML 页面和内容区域 iframe 中重新加载树导航 iframe 的最佳方法是什么?

树形导航 iframe 在 favorites.php(HTML 页面)中定义如下。

<iframe id="tnav" src="loadtreeb.php" style="border: 0px; width: 200px; height: 86%; overflow: auto;">
</iframe>

如果将节点添加到树中,则 HTML 页面中有一个按钮可以通过调用 savepages.php 来保存更新。该 php 文件被加载到内容 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> 

我从 savepages.php (内容 iframe)中重新加载树,如下所示。

<script type="text/javascript">
    $(document).ready(function() { 
        $('#tnav', window.parent.document).attr('src','loadtreeb.php');
    });
</script>

从 HTML 页面执行的其他操作也会从 javascript 重新加载 iframe。这是一种情况,删除项目按钮调用页面脚本中定义的 JavaScript 函数。

    <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');    
}

对 .attr('src','loadtreeb.php') 的调用都不会重新加载树导航,而不是

$('#tnav', window.parent.document).attr('src','loadtreeb.php' )

而不是

$('#tnav').attr('src','loadtreeb.php')

访问#tnav 肯定有问题。可能是什么问题?我认为添加位置 window.parent.document 来定位 #tnav 是从内容区域 iframe 内重新加载树形导航的正确方法。而省略位置是从 HTML 页面脚本中重新加载的正确方法。

  1. 还有其他问题是我没有考虑到的吗?
  2. 缓存有问题吗?
  3. 如何防止缓存树导航 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戏剧牡丹亭 2024-12-03 19:13:59

缓存似乎是问题所在。将其添加到 iframe 页面标题解决了问题。

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

谷歌搜索并在这里找到答案 http://www.webdeveloper.com/forum/showthread .php?t=64667

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文