【发布时间】:2010-09-03 21:45:16
【问题描述】:
我编写了一个 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 按设计覆盖整个窗口?感谢您的宝贵时间以及您可能提供的任何帮助!
顶部图片是所需的结果,并且是所有 aspx 页面上的结果。底部图片是我在经典的 asp 页面上得到的。
编辑:嗯,我想将 ASP 页面的所有重要部分都包装在一个 div 中(称为“divPage”),然后隐藏该 div。如果我调用“$('#divPage').hide();”,它就像一个魅力。来自 ASP 文件头部分的脚本 - 一旦文档加载,它就会隐藏 div。但是,我需要条件隐藏,所以我尝试将相同的代码放在我的 Jquery 文件中的 pop_init 函数中,尽管该函数中的其余代码对我来说执行完美,但隐藏 divPage 的代码什么也没做。任何想法为什么我会从 iniline 代码中得到不同的结果,而不是 RC_Jquery.js 文件中包含的函数?
【问题讨论】:
标签: jquery asp-classic timeout parent-child