2015年10月5日 星期一

Javascript note

1. Older examples may use a type attribute: <script type="text/javascript">
    The type attribute is not required. JavaScript is the default scripting language in HTML. (from W3school).
2. Script function can put any where such as <body> or <head>.
    Keeping all code in one place, is always a good habit. 
    It is a good idea to place scripts at the bottom of the <body> element.
    This can improve page load, because HTML display is not blocked by scripts loading.
    (from W3school).
3. external file by using .js
  <script src="myScript.js"></script>

    The advantages: (from W3school)
  • It separates HTML and code
  • It makes HTML and JavaScript easier to read and maintain
  • Cached JavaScript files can speed up page loads
4. Display functions:

  • Writing into an alert box, using window.alert().
  • Writing into the HTML output using document.write().
  • Writing into an HTML element, using innerHTML.
  • Writing into the browser console, using console.log().
5. 

沒有留言:

張貼留言