使用Javascript重定向PHP页面

时间:2014-02-07 22:18:38

标签: javascript php

<form action="" method="POST" onClick="submit" name="Formular">
<font face="Arial">VID:</font>
<input type="text" name="ID" size="6">
<input type="submit" value="Go" name="B1">
</form>
<?php //Form.php
//ID
if(isset($_REQUEST['ID']) && is_numeric($_REQUEST['ID']))
{
header("LOCATION: http://www.site.org/members/person/details.asp?Id=".(int)$_REQUEST['ID']);
exit;
}
?>

使用此表单我想在iFrame中执行或在JavaScript中打开一个新窗口。我怎么能这样做?

2 个答案:

答案 0 :(得分:0)

如果您想使用JavaScript重定向而不是php重定向,请更改:

if(isset($_REQUEST['ID']) && is_numeric($_REQUEST['ID']))
{
header("LOCATION: http://www.site.org/members/person/details.asp?Id=".(int)$_REQUEST['ID']);
exit;
}

到此:

if(isset($_REQUEST['ID']) && is_numeric($_REQUEST['ID']))
{
?>
<script>
self.location='http://www.site.org/members/person/details.asp?Id='+<?=$_REQUEST['ID']?>;
</script>
<?php
}

答案 1 :(得分:0)

if(isset($_REQUEST['ID']) && is_numeric($_REQUEST['ID']))
{
?>
<script>
window.location='http://www.site.org/members/person/details.asp?Id='+<?=$_REQUEST['ID']?>;
</script>
<?php
}