Alert
<script>
window.alert("Hello World!");
</script>
Write
<script>
document.script(5 + 6);
</script>
But if using document.write() after an HTML document is fully loaded, will delete all existing HTML.
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p>My first paragraph.</p>
<button οnclick="document.write(5 + 6)">Try it</button>
</body>
</html>
<script>
console.log(5 + 6)
</script>
Event | Description |
---|---|
onchange | An HTML element has been changed |
onclick | The user clicks an HTML element |
onmouseover | The user moves the mouse over an HTML element |
onmouseout | The user moves the mouse away from an HTML element |
onkeydown | The user pushes a keyboard key |
onload | The browser has finished loading the page |
Reference:http://www.w3schools.com/jsref/dom_obj_event.asp