想要关闭弹出窗口并在控制器上执行 PHP 脚本后重定向到相应的页面,没有任何事件
want to close popup and redirect to respective page without any event just after executing the PHP script on controller
我在控制器上有我的PHP代码,我有一个弹出窗口,之后完成弹出窗口的功能,我想要关闭我的弹出窗口和 wan 以重定向到相应的页面。我如何使用 PHP 实现这一点。我尝试使用以下代码,但它不起作用
$strRedirectUrl = $this->m_strSecureBaseName . 'Apartments/module/application_application_list/action/view_application_list/'; echo '<script type="text/javascript">
window.opener.location.replace(' . $strRedirectUrl . ');
window.close; <script>';
请帮助我。
谢谢
在弹出页面中调用此 JS:
window.opener.location.href = "http://some/new/location";
window.close();
PHP代码
echo"<script language='javascript'>";
echo("window.opener.location.href = '" . $strRedirectUrl . "';");
echo("window.close();");
echo "</script>";
演示:
第 1 页文件 : page_1.php
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
// Popup window code
function newPopup(url) {
popupWindow = window.open(
url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
</head>
<body>
<a href="JavaScript:newPopup('page_2.php');">Open a popup window</a>
</body>
</html>
第 2 页:文件 : page_2.php
<?php
$strRedirectUrl = "page_1.php";
echo"<script language='javascript'>";
echo("window.opener.location.href = '" . $strRedirectUrl . "';");
echo("window.close();");
echo "</script>";
?>
新编辑的代码
PHP代码
if (success condtion) {
$strRedirectUrl = "page_1.php";
echo"<script language='javascript'>";
echo("window.opener.location.href = '" . $strRedirectUrl . "';");
echo("window.close();");
echo "</script>";
}
else
{
echo json_encode(array(
'status' => 'error',
'message'=> 'error message'
));
}
Jquery Code
$.ajax({
type: "post",
url: "postride.php",
dataType:"json",
success: function (response) {
if(response.status === "error") {
// do something with response.message or whatever other data on error
} else {
return false;
}
}
});
相关文章:
- 可用于重定向到任何 URL 的 JavaScript 函数
- JavaScript没有'JSP页面重定向后无法工作..任何解决方案
- 如何侦听跨域映像请求上的任何301/302重定向状态代码
- 退出弹出重定向,但仅在退出时执行,而不是在单击页面上的任何其他 html 重定向按钮时执行
- 重定向到另一个页面而不发送查询字符串中的任何值
- 是否有任何 Javascript 函数可以重定向到另一个 HTML
- 想要关闭弹出窗口并在控制器上执行 PHP 脚本后重定向到相应的页面,没有任何事件
- 重定向那些没有任何引用URL的URL
- HTML POST->重定向工作,XMLHTTPrequest->重定向不起作用(无法从null发出任何请求
- 如何保留javascript变量,即使我重新加载或重定向到任何其他页面
- 禁用来自服务器的任何类型的重定向
- 重定向未刷新或点击任何内容的实时网站访问者
- 重定向到任何页面并提交表单详细信息
- 雅虎身份验证通过OAuth没有任何重定向(客户端).这可能吗?
- 有什么方法可以绑定'任何'通过身份验证脚本重定向(链接/刷新等)
- 是否有任何方法可以重定向到一个新的页面,并在该页面上用jquery编写一些内容
- 任何不触及窗口或文档的重定向方法
- 任何想法如何重定向一个页面到登录页面时,基于它的url刷新
- Jquery地图插件不做任何提交-重定向到"locator.html#"而不是发射形式的行动
- 在获取令牌期间重定向至m.box.com.没有任何象征性的回应