2012-05-05 12 views
1

시작 페이지의 중간에 회색 backgroud로로드되는 iframe 내에 로그인을 표시하려고하는데 iframe의 대상을 처리하는 데 문제가있어 다음과 같이 작동해야합니다. : 1- 사용자가 성공적으로 홈 페이지에 로그인 한 경우 부모 창에로드해야합니다. 2- 오류가 발생하면 오류 메시지가 iframe 자체에 표시되어야합니다.동적으로 양식의 대상 변경

내 코드 :

<div id="cover5" onclick="javascript:cover5();"> 
     <iframe name="warning" src="SignIn.php" id="warning" onclick="javascript:cover5();"> 
     </iframe> 
    </div> 

SignIn.php

<html> 
    <head> 
     <script type='text/javascript'> 
    function valid(){ 
    if(document.getElementById('username').value.toString().length>=1 || document.getElementById('password').value.toString().length>=1){ 
    return true; 
    } 
    else{ 
    alert("The Combination of username and password are Incorrect !"); 
    return false; 
    } 
    } 
</script> 
<script type='text/javascript'> 
function ChangeTarget() { 
    document.getElementById("login").prop("target", "_parent") 
} 
</script> 
<script type='text/javascript'> 
function ChangeText(text) { 
       document.getElementById("label1").innerHTML= text; 

      } 
     </script> 
     <title></title> 
    </head> 
    <body> 
<form name="login" id='login' target='_self' method='post' accept-charset='UTF-8'> 
<fieldset> 
<legend>SignIn</legend> 
<input type='hidden' name='submitted' id='submitted' value='1'/> 
<label for='username' >Email:</label> 
<input type='text' name='email' id='username' maxlength="50" /> <br /> 
<label for='password' >Password:</label> 
<input type='password' name='password' id='password' maxlength="50" /> <br /> 
<br /> <label id="label1" style="color: red"></label> <br /> 
<input type='submit' name='Submit' value='Login'/> <br /> 
<a href='resetPassword1.php'> Forgot/Reset Password? Click Here</a> 
</fieldset> 
</form> 

문제가 지금 모든 것을 그래서 그러나, 대상, PHP 코드 inisde라고 방법 ChangeTarget()에 의해 변경되지 않습니다 iframe 내부 또는 부모 윈도우 내부의 모든 내용을로드하십시오. 누구든지 문제를 해결하는 방법을 알고 있습니까?

서버 측 스크립트 :

mysql_select_db("mydb",$check); 
$email = $_POST['email']; //username that will be submit from a form 
$password = $_POST['password']; //password that will be submit from a form 

    // if(mysql_num_rows($temp_privileges_id)== 1) //if the id found that means that the user is already assigned to a conference 
    // { 
      echo '<script type="text/javascript">', 
      'ChangeTarget();', 
      '</script>'; 
      header('Location: main.php'); // transefer to home page with variable username 
    } 
+0

코드 호출 ChangeTarget은 서버 측입니까? 해당 부분에 대한 자세한 내용을 입력하십시오. –

+0

@KevinCollins 완료 –

+0

@KevinCollins이 함수를 올바르게 호출합니까? –

답변

1

있는 방법 prop 없습니다. 어느 target 값 직접

document.getElementById("login").target = "_parent"; 

속성 또는 setAttribute

document.getElementById("login").setAttribute("target", "_parent"); 
0
.prop()

는 jQuery를 기능 사용 설정이다. 당신이 jQuery를에 그것을 할 거라면, 이렇게 :

$("#login").prop("target", "_parent"); 

당신이 jQuery를에 그렇게하지 않을 경우, 바로 자바 스크립트에서 이런 식으로 작업을 수행합니다

document.getElementById("login").target = "_parent";