我一直在开发一个新的 .net MVC 站点,并集成了一些很棒的 jquery UI 组件。
我已经在 IE8、FF、opera 和 Chrome 中对其进行了测试,一切看起来都很好。当我在 IE7 中进行测试时,令人惊讶的是,是对话框导致了问题。
基本上发生的情况是,用户单击打开一个对话框,页面将立即滚动到页面底部。如果页面很长,这尤其糟糕。
这只发生在 IE7 中(可能是 6,但我什至不会去那里!)。
我花了几个小时阅读论坛,看来我不是唯一一个。
我创建了一个肮脏的黑客,我不喜欢它,但它确实有效。
onclick="SignIn(); <% if(ModelHelperClass.CheckForOldIEVersion() == true) Response.Write("window.scrollTo(0, 0);"); %> return false;">
还有其他人遇到过这个问题并在不诉诸肮脏黑客的情况下解决它吗?
我使用 jquery-ui-1.8.custom.min.js 和 jquery-1.4.2.min.js
非常感谢任何帮助
特鲁吉利
更新---
您好,感谢您的回复 -
在我的页面顶部我有此声明...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
我包括这些文件....
<link href="/Scripts/css/blitzer/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/Scripts/jquery-1.4.2.min.js" ></script>
<script type="text/javascript" src="/Scripts/jquery-ui-1.8.1.custom.min.js" ></script>
这是我的登录功能 - 其他对话框非常相似
// Sign in to the site
function SignIn()
{
$("#SignIn").dialog({
bgiframe: true,
modal: true,
resizable: false,
buttons: {
'Sign In': function () {
// the username and password
var Username = $("#Username").val();
var Password = $("#Password").val();
var dataString = 'Username=' + Username + '&Password=' + Password;
// AJAX here....
// when the user clicks sign in, the form is submitted
//$("#SignInForm").submit();
},
Cancel: function () {
$(this).dialog('close');
}
}
});
}
正如我所说,它在除 IE7 之外的所有浏览器中都能正常工作
最佳答案
我在 IE7 上遇到了同样的问题,并且使用的是最新版本的 jquery,并且没有任何杂散逗号。
事实证明修复很简单 - 只需添加 CSS 即可。添加 .ui-dialog{ position:absolute; Overflow:hidden }
在 IE7 中修复了该问题。
关于Jquery UI 对话框 - 打开 IE7 浏览器时立即移动到页面底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2945660/