简体   繁体   English

Javascript HTTP-EQUIV似乎不起作用

[英]Javascript HTTP-EQUIV Does Not Seem To Be Working

I would like to redirect a page with two defined variables in Javascript: 我想用Javascript中的两个已定义变量重定向页面:

if(isset($_POST['action'])){
        $task = $_POST['tasks'];
        $brand = $_POST['brands'];
        echo "<META HTTP-EQUIV='Refresh' Content='0; URL=brandmanagement.php?brand='$brand'&task='$task'>";    
    }

So the task and brand vars are getting from a form in the same page. 因此,任务和品牌变量是从同一页面中的表单获取的。 But after doing the process I get this EMPTY url: 但是在完成该过程之后,我得到了这个EMPTY网址:

brandmanagement.php?brand= brandmanagement.php?brand =

So why is that, how to fix it? 那为什么呢,如何解决呢?

Note that I don't want to use Header Location somehow! 请注意,我不想以某种方式使用标题位置!

Since you wish not to use the header function, then you should change this: 由于您不希望使用header功能,因此应更改以下内容:

echo "<META HTTP-EQUIV='Refresh' Content='0; URL=brandmanagement.php?brand='$brand'&task='$task'>";    

Into this: 变成这个:

echo "<META HTTP-EQUIV='Refresh' Content='0; URL=brandmanagement.php?brand=". $brand ."&task=". $task ."'>";    

Or: 要么:

echo "<META HTTP-EQUIV='Refresh' Content='0; URL=brandmanagement.php?brand={$brand}&task={$task}'>";    

Or: 要么:

echo "<META HTTP-EQUIV='Refresh' Content='0; URL=brandmanagement.php?brand=$brand&task=$task'>";    

(although the last one is less readable and can lead to dangerous side effects as php tries to parse variable names) (尽管最后一个可读性较差,并且由于php试图解析变量名而可能导致危险的副作用)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM