{"id":169,"date":"2013-06-19T15:41:26","date_gmt":"2013-06-19T22:41:26","guid":{"rendered":"http:\/\/courses.haigarmen.com\/isma309\/?p=169"},"modified":"2013-06-19T16:25:56","modified_gmt":"2013-06-19T23:25:56","slug":"embedding-and-including-javascript","status":"publish","type":"post","link":"https:\/\/courses.haigarmen.com\/isma309\/embedding-and-including-javascript\/","title":{"rendered":"Embedding and Including Javascript"},"content":{"rendered":"<p>Javascript is a programming language that is usually included or embedded into HTML files to add behaviours that HTML is not capable of.<\/p>\n<h3>Embedding<\/h3>\n<p>Here&#8217;s a simple example of how javascript is embedded in an HTML page:<\/p>\n<pre lang=\"HTML\">\r\n\t<html>\r\n\t\t<head>\r\n\t\t\t<title>This is a JavaScript example<\/title>\r\n\t\t\t<script language=\"JavaScript\">\r\n\t\t\t\t<!--\r\n\t\t\t\tdocument.write(\"Hello World!\");\r\n\/\/-->\r\n\t\t\t<\/script>\r\n\t\t<\/head>\r\n\t\t<body>\r\n\t\t\tHey there!\r\n\t\t<\/body>\r\n\t<\/html>\r\n<\/pre>\n<p><P><br \/>\nUsually, JavaScript code starts with the tag <\/p>\n<pre lang=\"HTML\"><script language=\"JavaScript\"><\/pre>\n<p>The javascript ends with the tag <\/p>\n<pre lang=\"HTML\"><\/script><\/pre>\n<p>.<\/p>\n<p>The javascript code is commonly placed between Head tags but sometimes it's embedded in the Body tags, like this:<\/p>\n<pre lang=\"HTML\">\r\n\t<html>\r\n\t\t<head><\/head>\r\n\t\t<body>\r\n\t\t\t<script>\r\n\t\t\t.....\/\/ The code embedded in the <body> tags.\r\n\t\t\t<\/script>\r\n\t\t<\/body>\r\n\t<\/html>\r\n<\/pre>\n<p>Why do we place JavaScript code inside comment fields <!-- and \/\/-->? It\u2019s for ensuring that the Script is not displayed by old browsers that do not support JavaScript. This is optional, but considered good practice. The LANGUAGE attribute also is optional, but recommended. You may specify a particular version of JavaScript:<\/p>\n<pre lang=\"HTML\">\r\n\t<script language=\"JavaScript1.2\">\r\n\t<\/pre>\n<h3>Including<\/h3>\n<p>You can use another attribute SRC to include an external file containing JavaScript code:<\/p>\n<pre lang=\"HTML\">\r\n\t<script language=\"Javascript\" src=\"hello.js\"><\/script>\r\n<\/pre>\n<p>For example, shown below is the code of the external file hello.js:<\/p>\n<pre lang=\"javascript\">\r\n\tdocument.write(\"Hello World!\")\r\n<\/pre>\n<p>\tThe external file is simply a text file containing JavaScript code with the file name extension \u201c.js\u201d.<\/p>\n<p>Next up: <a href=\"http:\/\/courses.haigarmen.com\/isma309\/write-and-writeln\/\" title=\"Write and Writeln\">Write and Writeln<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Javascript is a programming language that is usually included or embedded into HTML files to add behaviours that HTML is not capable of. Embedding Here&#8217;s a simple example of how javascript is embedded in an HTML page: This is a JavaScript example Hey there! Usually, JavaScript code starts with the tag . The javascript code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-169","post","type-post","status-publish","format-standard","hentry","category-exercises"],"_links":{"self":[{"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/posts\/169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/comments?post=169"}],"version-history":[{"count":9,"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/posts\/169\/revisions"}],"predecessor-version":[{"id":171,"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/posts\/169\/revisions\/171"}],"wp:attachment":[{"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/media?parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/categories?post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/isma309\/wp-json\/wp\/v2\/tags?post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}