【问题标题】:force left (nav) frame when show some pages显示某些页面时强制左(导航)框架
【发布时间】:2010-10-02 11:36:03
【问题描述】:

我有一个旧网站,左侧框架导航,右侧页面。

我希望当一个页面直接被 url'd 时,导航(左框架)也显示。

直到现在我还是一个 js 工作,但我不知道它从什么时候开始不工作, 现在返回此消息:

禁止 您无权访问此服务器上的 /master.html。 此外,在尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误。 Apache/2.2.10 (Unix) mod_ssl/2.2.10 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 服务器位于 www.cpis.es 端口 80

我使用的代码是

http://www.webmasterworld.com/forum21/1205.htm

Call this javascript code from the HEAD section of each child page. The code creates a variable from the URL of the page, and then passes that variable in the new location's URL. This means a "master" frameset can load this exact page in the content section: 

<SCRIPT LANGUAGE="JavaScript">
passpage = document.URL 
if (top.location == self.location) 
    top.location.href="master.html?" + passpage 
</script>
Then create just one "master.html" page. It holds the JavaScript code to decipher whatever URL is passed after the "?" and it writes that page into the content frame: 
<html> 
<head> 
<title>Master Frameset</title> 
</head> 
<script language="JavaScript" type="text/javascript"> 
origURL = parent.document.URL 
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length) 
document.write('<frameset cols="20%,80%"><frame src="leftnav.html" name="nav"><frame src="' + contentURL + '" name="content"><\/frameset>') 
</script> 
</html> 

谢谢,吉列尔莫。

【问题讨论】:

    标签: javascript html iframe


    【解决方案1】:

    抱歉耽搁了。

    看起来问题出在这个小小的 javascript 中:

    passpage = document.URL 
    if (top.location == self.location) 
     top.location.href="master.html?" + passpage 
    

    应该是:

    passpage = window.location.pathname;
    if (top.location == self.location) {
        top.location.href="master.html?" + passpage;
    }
    

    您必须在链接列表中的每个页面中更改该代码。我认为这应该可以解决问题。

    【讨论】:

      【解决方案2】:

      我刚刚检查了该网站,它现在似乎正在运行。我的猜测是服务器上没有位于http://www.cpis.es/master.html 的文件。

      如果问题仍然存在,请提供步骤,以便我们重现问题并查看问题所在。

      【讨论】:

        【解决方案3】:

        感谢 Maiku Mori,

        为了正确测试问题,请执行以下操作:

        • 转到 www.cpis.es
        • 单击菜单中的第二个选项 (CoPrint)
        • 好的,你看到leftnav +页面

        现在直接进入页面

        • 访问 www.cpis.es/coprint.htm
        • 错误,您进入了禁止页面。

        【讨论】:

          猜你喜欢
          • 2018-12-28
          • 2023-03-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-03-05
          • 1970-01-01
          相关资源
          最近更新 更多