2015-01-13 2 views
2

그래서이 입력을 지금 받았고 정상적으로 작동합니다. 하지만 같은 팝업으로 다른 페이지를 만들고 싶지만,이 것은 onclick 대신 자동으로 실행해야합니다. 작동 방법에 대한 정보는 무엇입니까?HTML/javascript onclick 대신 자동 팝업?

<input type="submit" id="checkin" method="post" action="checkin.php" href = "javascript:void(1)" onclick = "document.getElementById('light1').style.display='block';document.getElementById('fade').style.display='block'" value="Check in"> 
    <div id="light1" class="white_content"> 
     <form id="formen" name="myForm" action="checkin.php" method="POST">' 
     sAlot of content 
     </form> 
    </div> 

답변

2

1) 스크립트에서 팝업을 displaing에 대한 논리를 작성하고 제거 입력 태그

2

<div id="light1" class="white_content"> 
     <form id="formen" name="myForm" action="checkin.php" method="POST">' 
     sAlot of content 
     </form> 
    </div> 


<script> 
    document.getElementById('light1').style.display='block'; 
    document.getElementById('fade').style.display='block' 
</script> 
을) 또는 당신은 또한 trigge 수 있습니다 jquery를 사용하여 입력시 click 이벤트

<input type="submit" id="checkin" method="post" action="checkin.php" href = "javascript:void(1)" onclick = "document.getElementById('light1').style.display='block';document.getElementById('fade').style.display='block'" value="Check in"> 
    <div id="light1" class="white_content"> 
     <form id="formen" name="myForm" action="checkin.php" method="POST">' 
     sAlot of content 
     </form> 
    </div> 


<script> 
     $('#checkin').trigger('click'); 
</script> 
+0

감사합니다. D – Snoken

0
당신은 페이지로드의 "클릭"트리거 할 수 있습니다

: http://api.jquery.com/trigger/

를 예를 들면, :

$('#checkin').trigger('click'); 

난 당신이로 "onclick을"코드를 삽입해야합니다 여부를 기억할 수는 없지만 :

$('#checkin').on('click', function() { 

이 (IMO는 청소기이기 때문에 어쨌든 그것을 할 것이다)

0

onclick 이벤트가 아닌 닫는 body 태그 앞에 JS를 스크립트 태그에 포함시킬 수 있습니다.

0

onload 처리기에 body 태그의 스크립트를 onclick과 같은 방식으로 추가하십시오.

<body onload="document.getElementById('light1').style.display='block';document.getElementById('fade').style.display='block'"> 
    <!-- all your stuff --> 

</body>