【发布时间】:2012-08-22 07:36:33
【问题描述】:
我的 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;
}
【问题讨论】:
-
欢迎来到 SO!在添加按钮处理程序中运行
$.modal.close()之前是否存在 JavaScript 错误? -
@Jack 在错误控制台中没有显示错误
-
self.parent.tb_remove(),关闭 iframe 窗口。 -
抱歉,我不知道哪个 JavaScript 在哪个页面上; html 引用 parent.closewindow,但该函数似乎与单击处理程序上的添加按钮在同一页面中声明......非常混乱
-
php 标签是干什么用的? ;)
标签: php javascript