我有以下模态框 div -
<div class="modal fade" id="Community" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-content">
<button type="button" onclick="window.location.href='#Pricing'" data-dismiss="modal">Close and go to pricing</button>
</div>
</div>
单击按钮后,模式窗口将关闭,但不会转到 #Pricing 指示的正确部分。
你缺少一个'
in onclick
.
<button type="button" onclick="window.location.href='#Pricing'" data-dismiss="modal">Close and go to pricing</button>
Update
我想我知道原因了。事实上,就你的情况而言,onclick
之前被解雇data-dismiss="modal"
。这意味着,位置更改甚至会在模式关闭之前发生。但是,为了防止模式出现时页面滚动,主体将有一个modal-open
班级。这需要overflow: hidden;
,因此页面将无法滚动超过模式本身的高度。
要解决此问题,您需要将位置更改推迟到模式消失之后。您可以将其移动到回调中hidden.bs.modal
event.
事件文档可以在这里找到:http://getbootstrap.com/javascript/#modals-usage http://getbootstrap.com/javascript/#modals-usage .
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)