【问题标题】:session logout page issue in iframe using jsp/servlet使用 jsp/servlet 的 iframe 中的会话注销页面问题
【发布时间】:2012-08-31 10:36:22
【问题描述】:

您好,我正在使用 jsp/sevlet 在 Web 应用程序中工作,我正面临 iframe 中的会话注销页面问题

我在我的父页面中使用以下代码来解决我的会话超时

<script type="text/javascript">
    idleTime = 0;
    $(document).ready(function () {
        //Increment the idle time 2ounter every minute.
        var idleInterval = setInterval("timerIncrement()", 60000); // 1 minute

        //Zero the idle timer on mouse movement.
        $(this).mousemove(function (e) {
            idleTime = 0;
        });
        $(this).keypress(function (e) {
            idleTime = 0;
        });
    })
    function timerIncrement() {
        idleTime = idleTime + 1;
        if (idleTime == 15) { // 15 minutes
           window.location = "logoutPage.jsp"
        }
    }
</script>​​​​​​​​​​​​​​​​​​​​

我面临的问题是,如果一个进程在我的 iframe 页面中运行超出会话时间限制,那么父页面是 idel,因此它会自动注销

在其他情况下,如果我在 iframe 页面中使用会话超时代码,那么问题是

注销页面进入 iframe 页面

对于解开这个谜团有什么建议或其他解释吗? 请告诉我

【问题讨论】:

  • 所以您不想在父/iframe 页面中复制此代码并且仍然能够实现目标?
  • 在父/iframe 页面中复制此代码也会导致同样的问题

标签: java jquery jsp iframe session-timeout


【解决方案1】:

我终于找到了 Iframe 问题的解决方案

自动跳出 iframe

iframe 代表内联框架。 Iframe 是一种浮动框架,可以插入网页中的任何位置。

网站管理员对 iframe 的担忧是 iframe 可用于将您网站上的页面包含到外部网站中。

您如何防止您网站上的页面通过 iframe 被其他网站收录?

将以下 javascript 代码放置在您网站上所有页面的顶部将确保如果任何其他网站 iframe 对您网站上的页面进行 iframe,您的页面将脱离 iframe 并仅在用户浏览器中显示您的页面。

<script type="text/javascript">
<!--
    if (top.location!= self.location) {
        top.location = self.location.href
                   //or you can use your logout page as
                   //top.location='logout.jsp' here...
    }
//-->
</script>

在整个网站上实现 iframe 代码拆分的最佳方法是将代码放入外部 javascript 文件中,并将其包含在通用模板文件中。..

这对于充满这种神秘感的小伙伴们很有用.....

【讨论】:

    【解决方案2】:

    如果你觉得没问题,试试这个。

    iframe 放在不同的页面中,并使用JSP 的include 标记将该页面包含在您的主页中。

    那就试试看吧。

    我实际上认为iframe 与父页面保持不同

    【讨论】:

    • 实际上包含该页面对我没有帮助..因为在 iframe 内会运行 5 到 6 个页面..我想在这个 iframe 中显示的所有页面,所以请提供任何其他解决方案
    猜你喜欢
    • 1970-01-01
    • 2013-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多