php javascript alert redirect [英] php javascript alert redirect

查看:51
本文介绍了php javascript alert redirect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有


i希望显示一个警告框,然后通过php代码将页面重定向到另一个位置,但它不能正常工作。

As i不能使用PHP HEADER LOCATION因为我在标头之前使用echo。所以我必须使用javascript但是通过


PHP。

hi all

i want to show an alert box and then redirect page to another location through php code but its not working as needed.
As i cannot use PHP HEADER LOCATION because i m using echo before header. so i have to use javascript but through

PHP.

展开 | < span class =codeLinkonclick =selectAll(this);>选择 | 换行 | 行号

推荐答案

只要使用ob_start()函数启用输出缓冲,就可以将header()放在源文件中的任何位置。例如:
You can put header() anywhere in the source file, as long as you enable output buffering using the ob_start() function. For example:
展开 | 选择 | Wrap | 行号


未经授权


i修改了代码根据你的意思并且PHP Header重定向与ob_start()一起正常工作但警报不起作用。

hi unauthorised

i have amended code acording to you and the PHP Header redirect is working fine with ob_start() but the alert is not working.

展开 | 选择 | Wrap | 行号


@vinpkl


很明显,浏览器会被重定向到新页面之前javascript被执行(因为PHP在服务器上完成,浏览器上有Javascript)
@vinpkl
obviously, the browser is redirected to the new page before any javascript is executed (because PHP is done on the server and Javascript on the Browser)


这篇关于php javascript alert redirect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆