我的php脚本中有两个函数放在QandA2Table.php中,但是它们的按钮放在previousquestions.php页面中,因为模态窗口显示该页面的详细信息。模态窗口不关闭
反正我有两个按钮,下面是一个“关闭”按钮和“添加”按钮:
<div id="previouslink">
<button type="button" id="close" onclick="return parent.closewindow();">Close</button>
</div>
<?php
$output = "";
while ($questionrow = mysql_fetch_assoc($questionresult)) {
$output .= "
<table>
<tr>
<td id='addtd'><button type='button' class='add'>Add</button></td>
</tr>";
}
$output .= " </table>";
echo $output;
}
}
?>
我的问题是关闭模式窗口。当我点击“关闭”按钮时,它关闭了很棒的模式窗口,但是如果我点击一个“添加”按钮,它就不会关闭模态窗口。为什么是这样?
下面是两个按钮的功能:
function closewindow() {
$.modal.close();
return false;
}
$(".add").on("click", function(event) {
console.log("clicked");
var theQuestion = $("td:first-child", $(this).parent()).text();
if ($('.activePlusRow').length > 0) {
$('.activePlusRow').next('.textAreaQuestion').val(theQuestion);
}
parent.closewindow();
return true;
});
下面是IFRAME:
function plusbutton() {
// Display an external page using an iframe
var src = "previousquestions.php";
$.modal('<iframe src="' + src + '" style="border:0;width:100%;height:100%;">');
return false;
}
欢迎添加ID的iframe中创建者线SO !在添加按钮处理程序中运行'$ .modal.close()'之前是否存在JavaScript错误? –
@Jack没有错误显示在错误控制台 – user1394925
'self.parent.tb_remove()'中,关闭iframe窗口。 – Rafee