JavaScript Examples

Basic JavaScript Examples

  • Alert message - window.alert()
  • Several statements
  • Alert message w/ line breaks
  • Single-line JavaScript comment
  • Multi-line JavaScript comment
  • HTML comment
  • window.document.write()
  • Several window.document.write() statements (easier to edit)
  • Write content "on the fly"
  • Apply HTML tags within window.document.write()
  • Several sets of script tags in the same page

Return to Examples main menu