Lecture JS - Javascript APIs - Part 7
Lecture JS - Javascript APIs - Part 7
alert("This is an alert!");
const confirmed = confirm("Are you sure?");
const name = prompt("What's your name?");
prompt
<script>
} else {
</script>
<form>
<input type="button" id="Btn" value="Ask the Guru">
</form>
<script>
window.onload = function () {
document.getElementById("Btn").onclick = function () {
var question = prompt("What is your question o' seeker of JS knowledge?","");
if (question) {
alert("Good question. Who knows?");
}
else {
alert("At least you could ask a question.");
}
}
}
</script>
Window Properties
(partial list)
closed
document
frames[]
location (url)
name
navigator
parent
screen
Window Methods
(partial list)
Alert() – dialog box
Close() – close window
Confirm() – dialog box
Focus() – set focus
moveBy() – move relative to current position
moveTo() – move to new screen location
Open() – open new window
Prompt() – dialog box
setInterval() – execute code periodically
setTimeout() – execute code after a specified time
open
<button onclick="openNewWindow()">Open New Window</button>
<script>
function openNewWindow() {
window.open(
);
</script>