【问题标题】:open a modal window in jsp在jsp中打开一个模态窗口
【发布时间】:2012-03-18 22:51:38
【问题描述】:
我能够找到一种关于模态窗口的解决方案,这是链接:Simple jQuery Modal Window Examples。但是,我特别想要的是:
- 我想将 b.jsp 作为简单窗口模式打开,就像上面那个网站链接中给出的那样。
- 单击提交按钮后,我希望 b.jsp 以这种方式打开。
我尝试了几种解决方案,但我无法让它以相同的方式工作。
下面是我的代码:
a.jsp
<form action="b.jsp">
<input type="submit" value"click here to open modal window"/>
</form>
【问题讨论】:
标签:
javascript
jquery
window
modal-window
【解决方案1】:
使用 JQuery UI 非常简单。
我做了一些改变:
将类型更改为按钮,因为您不需要提交表单来加载 html。
<div id="resultreturn" style="display: none"></div>
<form >
<input type="button" value="click here to open modal window" id="loader"/>
</form>
后来我绑定了一个事件 click an in this event:
$(document).ready(function(){
$("#loader").click(function(){
// Load the page into the div
$("#resultreturn").load("b.html");
// Show the modal dialog
$("#resultreturn").dialog({ modal: true });
});
});
希望对你有帮助