从容器页面和内容 iframe 重新加载树导航 iframe
从包含树的 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 页面脚本中重新加载的正确方法。
- 还有其他问题是我没有考虑到的吗?
- 缓存有问题吗?
- 如何防止缓存树导航 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.
- 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
缓存似乎是问题所在。将其添加到 iframe 页面标题解决了问题。
谷歌搜索并在这里找到答案 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.
Googled and found that answer here http://www.webdeveloper.com/forum/showthread.php?t=64667