将 Jquery 超时代码集成到 ASP.NET 应用程序中的经典 ASP 表单中

发布于 2024-09-17 19:40:38 字数 3446 浏览 1 评论 0原文

我编写了一个 Jquery 函数,该函数在一定时间不活动后会黑屏,创建一个弹出窗口,允许用户单击按钮以保持登录状态,如果用户没有响应,则将其注销(关闭应用程序窗口)及时。

环境是ASP.NET(VB)。从技术上讲,我们不使用母版页,但我们确实有一个父页面,其中包含页眉、页脚和导航栏,并且从该窗口调用我的 Jquery 代码,并通过 IFrame 加载。

我们使用 txControl 的 ActiveX 版本作为应用程序中内置的文本编辑器。我们很快就会升级,但现在我已经有了一个经典的 ASP 页面,我需要将超时代码集成到其中,但是当超时代码启动时,ASP 文件不会像这样“黑屏”我猜,其余的子窗口和继续会话的按钮是不可见的,最终出现在 ASP 页面后面。

这是我的主要超时函数,它位于 .js 文件中,并通过脚本标记插入到父窗口中:

function pop_init() {
    // show modal div
    $("html").css("overflow", "hidden");
    $("body").append("<div id='popup_overlay'></div><div id='popup_window'></div>");
    //$("#popup_overlay").click(popup_remove);  // removed to make sure user clicks button to continue session.
    $("#popup_overlay").addClass("popup_overlayBG");
    $("#popup_overlay").fadeIn("slow");

    // build warning box
    $("#popup_window").append("<h1>Warning!!!</h1>");
    $("#popup_window").append("<p id='popup_message'><center>Your session is about to expire.  Please click the button below to continue working without losing your session.</center></p>");
    $("#popup_window").append("<div class='buttons'><center><button id='continue' class='positive' type='submit'><img src='images/green-checkmark.png' alt=''/> Continue Working</button></center></div>");

    // attach action to button
    $("#continue").click(session_refresh);

    // display warning window
    popup_position(400, 300);
    $("#popup_window").css({ display: "block" }); //for safari using css instead of show
    $("#continue").focus();
    $("#continue").blur();

    // set pop-up timeout
    SESSION_ALIVE = false;
    window.setTimeout(popup_expired, WARNING_TIME);
}

我已将“保持活动”代码附加到子窗口中的 mousedown、keydown 和模糊事件,如下所示:

<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        window.parent.reportChildActivity();
    });
</script>
<script type="text/javascript">
    $(document).bind("mousedown keydown blur", function() {        
            window.parent.reportChildActivity();
    });
</script>

我尝试将以下内容添加到我的 ASP 文件中,只是为了获得您在附图中看到的结果:

<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript" language="javascript"></script>
<script src="JScripts/RC_jquery.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        window.parent.reportChildActivity();
    });
</script>
<script type="text/javascript">
    $(document).bind("mousedown keydown blur", function() {
        window.parent.reportChildActivity();
    });
</script>

谁能告诉我需要做什么才能让 Jquery 超时 div 按设计覆盖整个窗口?感谢您抽出宝贵的时间以及您能够提供的任何帮助!

ShouldLook DoesLook 上面的图片是所需的结果,以及所有 aspx 页面上的结果。底部图片是我在经典的 asp 页面上得到的。

编辑:嗯,我想将 ASP 页面的所有基本部分包装在一个 div(称为“divPage”)中,然后隐藏该 div。如果我调用“$('#divPage').hide();”,它就像一个魅力。来自 ASP 文件头部分的脚本 - 一旦文档加载,它就会隐藏 div。但是,我需要有条件隐藏,因此我尝试将相同的代码放入 Jquery 文件中的 pop_init 函数中,尽管该函数中的其余代码对我来说执行得完美,但隐藏 divPage 的代码没有执行任何操作。你知道为什么我会从 iniline 代码中得到与 RC_Jquery.js 文件中包含的函数不同的结果吗?

I wrote a Jquery function that blacks out the screen after a certain amount of inactivity, creates a pop-up that allows the user to click a button to stay logged in, and logs them out (closing the application window) if they do not respond in time.

The environment is ASP.NET (VB). We don't technically use master pages, but we do have a parent page in which our header, footer and nav reside, and my Jquery code is called from that window, loaded via an IFrame.

We're using txControl's ActiveX version as our text editor built into the app. We're going to be upgrading very soon, but for now I've got this one classic ASP page that I need to integrate my timeout code into, but when the timeout code kicks in, the ASP file does not "black out" like the rest of the child windows, and the button to continue the session is invisible, ending up behind the ASP page, I'm guessing.

Here is my main timeout function, which is in a .js file and is inserted into the parent window via a script tag:

function pop_init() {
    // show modal div
    $("html").css("overflow", "hidden");
    $("body").append("<div id='popup_overlay'></div><div id='popup_window'></div>");
    //$("#popup_overlay").click(popup_remove);  // removed to make sure user clicks button to continue session.
    $("#popup_overlay").addClass("popup_overlayBG");
    $("#popup_overlay").fadeIn("slow");

    // build warning box
    $("#popup_window").append("<h1>Warning!!!</h1>");
    $("#popup_window").append("<p id='popup_message'><center>Your session is about to expire.  Please click the button below to continue working without losing your session.</center></p>");
    $("#popup_window").append("<div class='buttons'><center><button id='continue' class='positive' type='submit'><img src='images/green-checkmark.png' alt=''/> Continue Working</button></center></div>");

    // attach action to button
    $("#continue").click(session_refresh);

    // display warning window
    popup_position(400, 300);
    $("#popup_window").css({ display: "block" }); //for safari using css instead of show
    $("#continue").focus();
    $("#continue").blur();

    // set pop-up timeout
    SESSION_ALIVE = false;
    window.setTimeout(popup_expired, WARNING_TIME);
}

I've attached "stay-alive" code to mousedown, keydown and blur events in the child windows like this:

<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        window.parent.reportChildActivity();
    });
</script>
<script type="text/javascript">
    $(document).bind("mousedown keydown blur", function() {        
            window.parent.reportChildActivity();
    });
</script>

I tried adding the following to my ASP file, only to get the result you see in the attached image:

<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript" language="javascript"></script>
<script src="JScripts/RC_jquery.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        window.parent.reportChildActivity();
    });
</script>
<script type="text/javascript">
    $(document).bind("mousedown keydown blur", function() {
        window.parent.reportChildActivity();
    });
</script>

Can anyone tell me what I need to do to get the Jquery timeout div to overlay the entire window as designed? Thanks for your time and any assistance you may be able to provide!

ShouldLook
DoesLook
Top pic is the desired result, and the result on all the aspx pages. Bottom pic is what I'm getting on the classic asp page.

EDIT: Well, I thought to wrap all the essential parts of the ASP page in a div (called "divPage") and then hide the div. It works like a charm if I call "$('#divPage').hide();" from a script in the head section of the ASP file - it hides the div as soon as the document loads. However, I need conditional hiding, so I tried to put the same code in my Jquery file, in the pop_init function, and although the rest of the code in that function executes flawlessly for me, the code to hide divPage is doing nothing. Any ideas why I'd get different results from the iniline code, versus the function included in the RC_Jquery.js file?

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

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

发布评论

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

评论(1

憧憬巴黎街头的黎明 2024-09-24 19:40:38

jQuery 是所有客户端编码 ASP 是服务器端 - 此帖子需要移至 jQuery 论坛/标签

jQuery is all client-side coding ASP is server side - this posting needs to be moved to a jQuery forum/tag

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