javascript 在jsp中打开一个模态窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9499351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 06:53:30  来源:igfitidea点击:

open a modal window in jsp

javascriptjquerywindowmodal-window

提问by Tom

I was able to find one solution regarding modal windows, here is the link: Simple jQuery Modal Window Examples. However, what I want specifically is:

我找到了一个关于模态窗口的解决方案,这里是链接:Simple jQuery Modal Window Examples。但是,我特别想要的是:

  • I want to open b.jsp as a Simple Window Modal, like the one given in that website link above.
  • After clicking the submit button I want b.jsp to open in that manner.
  • 我想将 b.jsp 作为一个简单的窗口模式打开,就像上面那个网站链接中给出的那样。
  • 单击提交按钮后,我希望 b.jsp 以这种方式打开。

I tried several solutions, but I can't get it to work the same way.

我尝试了几种解决方案,但我无法让它以同样的方式工作。

Here is my code below:

这是我的代码如下:

a.jsp

<form action="b.jsp">
<input type="submit" value"click here to open modal window"/>
</form>

回答by Víctor Due?as Robles

Using JQuery UI is very easy.

使用 JQuery UI 非常简单。

I do some changes:

我做了一些改变:

Change type to button because you don′t nee sudmit form for load html.

将类型更改为按钮,因为您不需要加载 html 的提交表单。

<div id="resultreturn" style="display: none"></div>
<form >
<input type="button" value="click here to open modal window" id="loader"/>
</form>

Later I bind a event click an in this event:

后来我绑定了一个事件 click an 在这个事件中:

$(document).ready(function(){
    $("#loader").click(function(){
                // Load the page into the div
        $("#resultreturn").load("b.html");
                // Show the modal dialog
        $("#resultreturn").dialog({ modal: true });
    });
});

I hope this help you

我希望这对你有帮助