Javascript 在模式框中打开页面

Javascript 在模式框中打开页面,javascript,php,jquery,Javascript,Php,Jquery,我有一个脚本,限制点击a href链接(如果有);没有选中复选框。我想在模式框中打开editpr.php。问题是我不熟悉modalbox。有什么帮助吗 <a class="button edit" style="cursor:pointer;" ><span><b>Edit Purchase Request</b></span></a> <a class="button remove" style="cursor:po

我有一个脚本,限制点击a href链接(如果有);没有选中复选框。我想在模式框中打开editpr.php。问题是我不熟悉modalbox。有什么帮助吗

<a class="button edit" style="cursor:pointer;" ><span><b>Edit Purchase Request</b></span></a>
<a class="button remove" style="cursor:pointer;" name="remove"><span><b>Remove Purchase Request</b></span></a> 

有一些有用的jQuery插件可以让您的工作变得非常简单。我建议你试试看。您有一个例子。

仅使用纯javascript无法在模式框中打开页面,例如“alert()”或“confirm()”

要想做你想做的事情,你需要将你的“editpr.php”内容放在一个div中,并使用CSS使其成为模态

事实上,我们有很多库,使其易于实现,我认为最常用的是:


在这个示例页面上选中“外部HTML(Ajax)”和“外部网页(Iframe)”,可能与您想做的事情相同:

既然您已经在使用jQuery,那么您可以使用jQuery ui

他们有一个你想在这里做什么的例子:

一旦获得模态对话框元素设置,您所要做的就是make和XHR for editpr.php,将结果加载到元素innerhtml中,然后显示对话框

// setup your modal dialog
var el = $( "#editpr-dialog" ).dialog({
  // ... (other config options)
  modal: true
});

// XHR editpr.php and show the dialog box
$.get('editpr.php', function(data){
  el.html(data).dialog('open');
});

custombox插件有很多漂亮的特性,与Jquery配合使用效果惊人:

我将脚本添加到我的脚本中?如何将脚本合并到我的脚本中?我不太擅长使用脚本
// setup your modal dialog
var el = $( "#editpr-dialog" ).dialog({
  // ... (other config options)
  modal: true
});

// XHR editpr.php and show the dialog box
$.get('editpr.php', function(data){
  el.html(data).dialog('open');
});