0

我在 index.html 中使用 iframe 标签。下面是代码

<iframe src="header.html" height="100px" scrolling="no" width="1335px"
        style="position: absolute; top: 0px;"></iframe>
    <iframe src="menu.html" height="500px" scrolling="no" width="250px"
        style="position: absolute; top: 103px;"></iframe>
    <iframe src="body.html" height="500px" scrolling="no" width="1083px"
        style="position: absolute; top: 103px; left: 260px"></iframe>
    <iframe src="footer.html" height="100px" scrolling="no" width="1335px"
        style="position: absolute; top: 605px;"></iframe>

我的登录 div 在 menu.html 中,注销在 footer.html 中。我想在隐藏登录 div 时显示注销(登录后),当我单击注销时,我希望隐藏我的注销链接并显示登录 div。由于它们都在不同的 html 中,所以我想知道我们如何同时做到这一点。现在这个功能正在工作,但我需要刷新页面。window.location.reload 也没有用。有没有更简单的方法可以同时在多个 html 中执行隐藏/显示操作。

4

1 回答 1

0

如果您确实必须将此内容保存在单独的文件中并且打算为每个文件单独调用,请尝试以下操作:

<div id="header" style="height: 100px; width 1335px; overflow: hidden; position: absolute; top: 0px;"></div>
<div id="menu" style="height: 500px; width 250px; overflow: hidden; position: absolute; top: 103px;"></div>
<div id="body" style="height: 500px; width: 1083; overflow: hidden; position: absolute; top: 103px; left: 260px;"></div>
<div id="footer" style="height: 100px; weight:1335px; overflow: hidden; position: absolute; top: 605px;"></div>

还有一些像这样的jQuery:

<script>
$(document).ready(function() {
   $("#header").load("header.html");
   $("#menu").load("menu.html");
   $("#body").load("body.html");
   $("#footer").load("footer.html");
});
</script>

现在您已经在同一个窗口中拥有了所有标记,使用 jQuery 来做任何您想做的事情。

于 2013-03-31T15:44:00.023 回答