2013-06-21 2 views
-1

두 개의 html 페이지가 있습니다. 하나는 Login.html이고 다른 하나는 index.html입니다. 사용자가 로그인 버튼을 클릭 할 때마다 index.html으로 이동하려고합니다 (그러나 정상적인 href 연결은 아닙니다).Jquery를 사용하여 단일 페이지에서 탐색

색인 페이지는 login.html 코드에도 있어야합니다. 단일 페이지 탐색과 같습니다.

동일한 기능을하는 플러그인이 있습니까?

은 내가 버튼을 클릭하면이 단지의 컨테이너 사업부를 보여줍니다 그것은 부하에 로그인 페이지를 표시하지만, 이

<script type="text/javascript"> 

      function hideDiv() { 
     document.getElementById("container").style.display = 'none';  
    } 

    function showDiv() { 
    document.getElementById('container').style.display = "block"; 
} 


     </script> 

HTML 페이지

  <div class="masthead"> 
       <h3 class="muted"> 
       <sapn class="login-logo"><img src="img/QuadAnalytix_reg350x47.png"/> 
       </span></h3> 
      </div> 

      <div id="loginformcontainer"> 

       <form> 
        <label> Username: 
         <input type="text" name="uname"> 
        </label> 
        <label> Password: 
         <input type="password" name="pwd"> 
        </label> 
        <div class="buttons1"> 
         <button type="submit" id="submit" value="Login" class="btn" onclick="showDiv()"> 
          Submit 
         </button> 
         <button type="reset" id="reset" value="Reset" class="btn"> 
          Clear All 
         </button> 
        </div> 
        <div> 




<div id="container"> 

//index.html page 

</div> 
</body> 
</html> 

시도 두번째 .. 내가 여기서 뭘해야하지?

+0

이것은 혼란 스럽습니다. 왜 그게 필요합니까 ?? – bipen

+0

'onclick = "location.href ('index.html')"'이게 뭔가? – Jai

+1

? 그것의 likeksinglke 페이지 탐색. ? – yeyene

답변

0

는 AJAX 기능을 사용하여 같은 load()

,

$('body').load('index.html', function() { 
    alert('Load was performed.'); 
}); 
0

당신이 이것을 달성 할 수를 사용해보십시오. 코드로 문제를 자세히 설명 할 수 있으면 사용할 수있는 코드를 사용하여 도움을 얻을 수 있습니다. 같은 내에서 다른 페이지를로드

가장 간단한 방법은 다음과 같습니다 -

$('body').load('index.html', function() { 
    alert('Page loaded'); 
}); 
+0

어떻게 든 제 코드처럼 보입니다. –

+0

수정 된 질문을 확인하십시오 !!! – Ash

1

당신은 그 archieve하는 AJAX와 약간의 자바 스크립트를 사용할 수 있습니다. 예를 들어

, 뭔가 같은 :

HTML :

<div id = "index"> 
    <input type="button" id="loginButton" value="login"></input> 

    <div id="login" style="display: none;"> 
     Welcome to the site. 
    </div> 
</div> 

JAVASCRIPT (JQUERY) :

$('#loginButton').click(function() { 
    $.post('login.php', function(data) { // HERE YOU LOGIN 
     $('#login').show(); 
    }); 
); 
+0

편집 된 질문을 확인하십시오. – Ash

+0

@Ash 당신은'input type = "submit"을 사용하고 있습니다. 양식을 제출하면 페이지가 다시로드되고 DIV가 숨겨진 첫 번째 단계로 돌아옵니다. 따라서 AJAX를 대신 사용해야하므로 페이지를 다시로드하지 않거나 다시로드하려는 경우 서버에서 반환 된 변수를 사용하여 div를 표시하거나 숨길 시점을 알아야합니다. – maqjav

관련 문제