1 💙 Flashcards
3 ways to add JS to web page
- Embedding
- External JS file
- Placing code directly into HTML file onclick attribut
Embedding is
is
Embedding
How to add external js file
<script> </script>
Placing code directly inside html tag
Onclick attribute
External file useful if
Want some scripts to be available
Classic example comment
//
Single-line comment
//
Multi-line comment
/* */
Output data
Console.log()
Debugging ir code prints it to the console
Console.log()
Press ….. to show vonsole in page
F12
Alert dialog boxes
Display data to user
Alert dialog boxes Created with the use of
Window.alert()
Display data to users
Alert dialog boxes
Window.alert() is
Method
Short quick informative messages
Window.alert()
Window.alert()
Short quick informative messages
Write the content to the current document
document.write()
document.write()
Delete all html
Delete all html
document.write()