<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<p>
<label>prevent event on</label
><input
id="prevent"
type="checkbox"
name="eventprevent"
value="on"
/>
</p>
<p>
<a
href="http://naver.com"
onclick="if(document.getElementById('prevent').checked) return false;"
>NAVER</a
>
</p>
<form
action="http://naver.com"
onsubmit="if(document.getElementById('prevent').checked) return false;"
>
<input type="submit" value="제출" />
</form>
<p>
<label>prevent event on</label
><input
id="prevent"
type="checkbox"
name="eventprevent"
value="on"
/>
</p>
<p>
<a href="http://opentutorials.org">opentutorials</a>
</p>
<form action="http://opentutorials.org">
<input type="submit" />
</form>
<script>
document.querySelector("a").onclick = function (event) {
if (document.getElementById("prevent").checked) return false;
};
document.querySelector("form").onclick = function (event) {
if (document.getElementById("prevent").checked) return false;
};
</script>
<p>
<label>prevent event on</label
><input
id="prevent"
type="checkbox"
name="eventprevent"
value="on"
/>
</p>
<p>
<a href="http://opentutorials.org">opentutorials</a>
</p>
<form action="http://opentutorials.org">
<input type="submit" />
</form>
<script>
document
.querySelector("a")
.addEventListener("click", function (event) {
if (document.getElementById("prevent").checked)
event.preventDefault();
});
document
.querySelector("form")
.addEventListener("submit", function (event) {
if (document.getElementById("prevent").checked)
event.preventDefault();
});
</script>
</body>
</html>