- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在做一个 MVC 应用程序。这是我的 _Layout.cshtml
我需要将其移动到 js 文件
<script type="text/javascript">
window.SessionTimeout = (function() {
var _timeLeft, _popupTimer, _countDownTimer;
var stopTimers = function() {
window.clearTimeout(_popupTimer);
window.clearTimeout(_countDownTimer);
};
var updateCountDown = function() {
var min = Math.floor(_timeLeft / 60);
var sec = _timeLeft % 60;
if(sec < 10)
sec = "0" + sec;
document.getElementById("CountDownHolder").innerHTML = min + ":" + sec;
if(_timeLeft > 0) {
_timeLeft--;
_countDownTimer = window.setTimeout(updateCountDown, 1000);
} else {
document.location = "Home/TimeOutPage";
}
};
var showPopup = function() {
_timeLeft = 60;
updateCountDown();
ClientTimeoutPopup.Show();
};
var schedulePopup = function() {
stopTimers();
_popupTimer = window.setTimeout(showPopup, @PopupShowDelay);
};
var sendKeepAlive = function() {
stopTimers();
ClientTimeoutPopup.Hide();
SessionTimeout.schedulePopup();
};
return {
schedulePopup: schedulePopup,
sendKeepAlive: sendKeepAlive
};
})();
我尝试仅复制脚本标记之间的代码,但它不起作用。我知道问题出在函数签名上
window.SessionTimeout = (function() { ...
但我不知道如何在 js 文件中使用 window.SessionTimeout。
@PopupShowDelay 在我看来是这样定义的:
@functions {
public int PopupShowDelay
{
get { return 60000 * (Session.Timeout - 1); }
}
}
更新
好的,我发现错误了。问题是变量
@PopupShowDelay
我在 View 中定义了它,并尝试读取.js文件。
所以,我要检查一下: Passing parameters to JavaScript files
谢谢!!
最佳答案
嵌套函数中的 this
上下文可能会出现问题。 You can read more here
关于javascript - 将 window.SessionTimeout 脚本传递到 js 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23704797/
我确信这个问题被问过很多次,但我找不到一个好的解决方案。 当用户单击注销时,控件将转到 /sessiontimeout 而不是 /logout。我见过不同的解决方案,其中建议将 invalidate-
我正在尝试找出一种动态更改 session 超时的方法,因为我的客户要求这是一个他们可以轻松更改的值(就好像它是数据库事务一样)。这是我要更改的值的截断版本: 我正在使用 C#/.Net
我正在做一个 MVC 应用程序。这是我的 _Layout.cshtml 我需要将其移动到 js 文件 window.SessionTimeout = (function() { var _t
我正在尝试使 Java 中的 HttpSession 超时。我的容器是 WebLogic。 目前,我们在 web.xml 文件中设置了 session 超时,如下所示 15 现在,有人告诉
在我们的一个项目中,我们遇到了随机 session 超时问题。根据最近的发现,我注意到 Sitecore Analytics.Robots.SessionTimeout 可能是导致它的原因。 我们注意
在我们的一个项目中,我们遇到了随机 session 超时问题。根据最近的发现,我注意到 Sitecore Analytics.Robots.SessionTimeout 可能是导致它的原因。 我们注意
在我的站点中,我有一个 从 rss.cfm 加载 RSS 提要.下面的代码如预期的那样在 60 秒后刷新 RSS 提要。 但是,它最初不会加载 直到第一个 60 秒过去之后。它还会导致 session
下面的代码似乎不再在 ASP.NET Identity 中工作?这是正确的吗? Global.asax protected void Session_Start(object sender, Even
我是一名优秀的程序员,十分优秀!