2011-04-07 70 views
0

我在打开链接时打开jQuery对话框。对话框打开状态良好,但页面向下滚动到页面,因此我无法看到对话框,直到向上滚动。我该如何避免这种情况?单击链接时滚动到页面底部?

<script language="javascript" type="text/javascript"> 
    $(document).ready(function() { 
      jQuery("#waitDialog").dialog({ 

      autoOpen: false, 
      modal: true, 
      height: 375, 
      position: 'center', 
      width: 400, 
      draggable: true,     
      closeOnEscape: false, 
      open: function (type, data) { 
       $(".ui-dialog-titlebar-close").hide(); 
       $(this).parent().appendTo("form"); 
      } 
     }); 
    }); 
    function showDialog(id) { 
      $('#' + id).dialog("open");  
    } 
</script> 
<div id="waitDialog" style="display:none; cursor: default">   
    <table class="ms-authoringcontrols" style="border-top:1px black solid; border:1px black solid; height:70px " > 
    <tbody> 
      <tr> 
     <td class="ms-sectionheader ms-rightAlign"> 
      Please wait. 
     </td> 
      </tr> 
    </tbody> 
    </table> 
    </div> 

<map name="Map"> 
    <area shape="rect" coords="225,16,287,33" href="/_layouts/MyAlerts.aspx" onclick="javascript:showDialog('waitDialog');" alt="My Alerts"> 
</map> 
+0

我们可以看到您的链接的代码? – mattsven 2011-04-07 19:22:56

回答

1

.click()事件为你的链接应该return false,使其没有得到遵守,导致页面跳转到你的元素与id

$('a').click(function() { 
    showDialog($(this).attr('href')) 
    return false; 
}); 
0

这听起来像你有一个锚标记的问题。而不是href="/_layouts/MyAlerts.aspx"

你可以使用:

onclick='window.location = "/_layouts/MyAlerts.aspx"; 
相关问题