jQuery:如何打开对话框窗口 [英] jQuery: how to open a dialog window
问题描述
我的网页上有一个按钮;我的期望是当我单击按钮时,它会提示一个对话框窗口;在对话框窗口中,它具有是/否按钮;如果我单击是,它将打开一个新页面(由php继承);如果单击否,则保留在旧页面上.我该怎么办?
I have a button in a my webpage; my expectation is when I click the button, it prompts a dialog window; in the dialog window, it has yes/no button; if I click yes, it opens a new page (gereated by php); if I click no, I stay on the old page. How can I do that?
<input type="button" name="terminate" value="terminate" id="terminate" title="Terminate" onclick="terminateIt();"/>
推荐答案
有无数种方法可以做到这一点.
There are innumerable ways to do this.
最常见的方法可能是使用 jQuery UI的对话框.
Probably the most common way would be to use jQuery UI's Dialog.
他们的演示中有一个带有两个按钮的对话框示例.这是该演示的摘要:
They have an example in their demo of a dialog with two buttons. Here is a snipped from that demo:
HTML:
<div id="dialog-confirm" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Your question goes here. Are you sure?</p>
</div>
JS:
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
Yes: function() {
window.open(....);
$( this ).dialog( "close" );
},
No: function() {
$( this ).dialog( "close" );
}
}
});
查看整个jQuery UI库.大量的好东西可以很容易地做一些基本的事情.
Check out the whole jQuery UI library. Tons of great stuff making it easy to do some basic things.
这篇关于jQuery:如何打开对话框窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!