<!DOCTYPE html>
<
html
>
<
head
>
<
title
>returnValue event property</
title
>
<
style
>
h1 {
color: green;
}
body {
text-align: center;
}
</
style
>
</
head
>
<
body
>
<
h1
>GeeksforGeeks</
h1
>
<
script
type
=
"text/javascript"
>
function WriteInformation(message) {
var inform = document.getElementById("info");
inform.innerHTML += message + "<
br
/>";
inform.scrollTop = inform.scrollHeight;
}
function CancelEvent(event, NameEvent) {
if ('cancelable' in event) {
if (event.cancelable) {
event.preventDefault();
WriteInformation(
"The " + NameEvent +
" event is canceled");
} else {
WriteInformation(
"The " + NameEvent +
" event is not cancelable");
}
} else {
event.returnValue = false;
WriteInformation(
"The " + eventName +
" event is maybe canceled");
}
}
</
script
>
In this it cancels the onclick event for the checkbox
<
br
/> and the onchange event for the selection list below.
<
br
/> The onclick event is cancelable, the onchange is not.
<
br
/>
<
br
/>
<
input
type
=
"checkbox"
onclick
=
"return false;"
/>
Try to check this checkbox.
<
br
/>
<
br
/> Select one of the one options.
<
select
onchange
=
"return false;"
>
<
option
>First option</
option
>
<
option
>Second option</
option
>
</
select
>
</
body
>
</
HTML
>