[英]How can I preserve the page scroll position when opening a dialog in response to a link trigger?
I would like to know how I can maintain the scroll position when I open a jQuery dialog. 我想知道当我打开jQuery对话框时如何保持滚动位置。
Here is the code I'm using to open my dialog: 这是我用来打开对话框的代码:
<a class="link" onclick="openmyDialog();" href="#">Open a dialog</a>
And the function : 和功能:
function openmyDialog()
{
$("#dialog").dialog('destroy');
$("#dialog").html("msg");
$("#dialog").dialog(
{
buttons:
{
"Yes": function()
{
$(this).dialog("close");
}
},
resizable: false,
draggable: true,
modal: true,
title: 'Error'
});
return false;
}
您没有将返回值正确返回给点击处理程序:
onclick="return openmyDialog();"
使用<a href="javascript:void(0);"></a>
代替“#”?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.