자동 버튼 클릭 코드 자동클릭 코드
<!-- 자동클릭 이동 -->
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>자동 클릭 & 페이지 이동 버튼</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
#autoClickButton {
padding: 15px 30px;
font-size: 20px;
cursor: pointer;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
transition: background-color 0.3s ease;
}
#autoClickButton:hover {
background-color: #45a049;
}
#message {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<div>
<button id="autoClickButton">자동 클릭 후 이동할 버튼</button>
<p id="message"></p>
</div>
<script>
const button = document.getElementById('autoClickButton');
const messageDisplay = document.getElementById('message');
const delayInSeconds = 5; // 5초 후에 자동 클릭
const targetURL = 'ㅡㅡ주소입력ㅡㅡ'; // 이동할 주소 (여기에 원하는 주소 입력)
// 버튼 클릭 시 실행될 함수
function handleClick() {
messageDisplay.textContent = '페이지로 이동합니다...';
button.disabled = true; // 한 번 클릭되면 비활성화
button.style.backgroundColor = '#cccccc'; // 비활성화 색상 변경
// 설정된 URL로 페이지 이동
window.location.href = targetURL;
}
// 일정 시간 후에 handleClick 함수를 호출 (자동 클릭)
setTimeout(() => {
if (!button.disabled) { // 이미 클릭되지 않았다면
button.click(); // 버튼을 프로그램적으로 클릭
}
}, delayInSeconds * 1000); // 밀리초 단위이므로 초 * 1000
// 사용자가 직접 버튼을 클릭했을 때
button.addEventListener('click', handleClick);
messageDisplay.textContent = `${delayInSeconds}초 후에 버튼이 자동으로 클릭되고, ${targetURL}로 이동합니다.`;
</script>
</body>
</html>
<!-- 자동 클릭 이동 -->