Theme Layout

Boxed or Wide or Framed

Wide

Theme Translation

Display Featured Slider

Featured Slider Styles

Display Grid Slider

yes

Grid Slider Styles

Display Trending Posts

Display Author Bio

Display Instagram Footer

off

Dark or Light Style

Light

Blog Archive

Powered by Blogger.

Thursday, February 9, 2017

JS Tutorial ) Where To


# JavaScript Where TO...



The <Script> Tag

In HTML, JavaScript code must be inserted between <script> & </script>


<Used Atom editor>


JavaScript in <head> or <body>

I can Place any number of scripts in an HTML document. Scripts can be placed in the <body>, or in the <head> section of an HTML page, or in both.

JavaScript in <head>

In below example, a JavaScript function is placed in the <head> section of an HTML Page. The function is invoked when a button clicked:
<Example Code>
Result is as follows.

<Before Click>
<After Click>


JavaScript in <body>

In this example, a JavaScript function is placed in the <body> section of an HTML Page. The function is invoked when a button is clicked:

<Example Code>
Result is as follows:

<Before Click>
<After Click>


External JavaScript

Scripts can also be placed in external files:


<Example HTML Code>
<Example JSP Code>




<Before Click>


<After Click>







External JavaScript Advantages

  • It separates HTML and code
  • It makes HTML and JavaScript easier to read and maintain
  • Cached JavaScript files can speed up page loads

External References

 External Scripts can be referenced with a full URL or with a path relative to the current web page. 
 This example uses a full URL to link to a script:




 This example uses a script located in a specified folder on the current web site:


 This example links to a script located in the same folder as the current page:



** HTML File Paths 


QuickEdit
Unknown
0 Comments
Share This Post :

You Might Also Like

No comments:

Post a Comment

Follow @SunriseSunsetBlog