2010-08-04 5 views
2

iframe에서 로그인이 성공하면 자바 스크립트 리디렉션을 주 윈도우로 사용하려고합니다. 이 내 코드입니다 :JavaScript가 주 윈도우로 리디렉션되지 않아서 http 옵션 (&)이 적용되지 않습니다.

if ($_GET['redirect']!='') { 
    $redirect=$_GET['redirect']; 
    $smart->assign('redirect',$redirect); 
} 
$redirect=$_GET['redirect']; 
echo $redirect; 

if(isset ($_SESSION['user'])&&$_SESSION['user']!='') { 

    $user->email=$_SESSION['user']; 
    $user->addCorporate(); 
    $user->signIn(); 
    $user->loadSession(); 

    echo("<script language=\"javascript\" type=\"text/javascript\">"); 
    echo "document.write('redirecting...');"; 

    if ($redirect!='') { 
     echo 'self.parent.location = "'.$redirect.'"'; 
    } else 
     echo 'self.parent.location = "index.php"'; 
    //echo $redirect; 

    // redirect($redirect); 
    echo "</script>"; 
} 

에코 $redirect 표시 http://xxxxxxxx/play.php?action=play&id=d59541b89828da34e9a8345a1bdafe2b 하지만 재 지정 http://xxxxxxxx/play.php로 만들어? (PHP 옵션 없음)

+1

btw 잃어버린 물건은 PHP에만 국한되는 것이 아니라 일반적으로 HTTP와 URL 매개 변수라고합니다. 그게 공식 제목이 맞는지는 모르겠지만 그렇게 부르면 질문에 사람들을 끌어 들일 수 있습니다. – Nicolas78

답변

1

이것은 꽤 이상하게 들립니다. 다음은 진행 방법입니다. 브라우저에서 JavaScript를 끄고 작성한 JavaScript를 검사하십시오. 그렇다면 최소한 이상한 이유로 URL이 잘못 인쇄되거나 문제가 리디렉션 부분에 있는지 여부를 알 수 있습니다.

+0

echo 'alert ("'. $ redirect. '")'; xxxxxx/play.php? action = play (옵션 없음) – kossibox

+1

이상하게 표시됩니다. 하지만 실제로 & nbsp; 문자열 뒤에는 &! 그것은 또한 귀하의 질문에 줄 바꿈으로 표시되기 때문에 (ID는 새 줄에서 시작). – Nicolas78

0

당신이 라인을 변경하면이에

echo 'self.parent.location = "'.$redirect.'"'; 

: 어떻게됩니까

echo 'alert("'.$redirect.'")'; 

를?

+0

안녕하세요, 경고가 표시됩니다. http : //xxxxxx/play.php? action = play (without ooption) – kossibox

관련 문제