Okay, I am trying to run a code in JavaScript that asks the user if they want to view a video. If they do, then a video would play, if not, then it won't. Basically, I am using an html5 code for the video and I am not sure how to only show the video if the user clicks OK. I am hoping for something along the lines that the video player won't even show up unless they click Okay.
var something = confirm("Want to watch a video?");
if (something) {
//Run the HTML to play the video
} else {
alert("Okay.");
}
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' href='style.css' />
<script src='script.js'></script>
</head>
<body>
<video width='320' height='240' controls>
<source src='videolink.mp4'>
Your browser does not support the video tag.
</video>
</body>
</html>
This is a very simple example of what I am trying to do. Anyways, that's it. All help appreciated.