{"id":207,"date":"2011-09-14T15:38:56","date_gmt":"2011-09-14T15:38:56","guid":{"rendered":"http:\/\/javascript-tutor.net\/?p=207"},"modified":"2012-12-25T16:33:11","modified_gmt":"2012-12-25T16:33:11","slug":"changing-color-webpage-days-week","status":"publish","type":"post","link":"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/","title":{"rendered":"Changing color of webpage according to days of week"},"content":{"rendered":"<p>It is quite simple to change the background color of the webpage according to the days of a week. You can do this by using a series of ifs. The code is as follows, but it only works in Internet Explorer.<\/p>\n<div id=\"_mcePaste\">&lt;script language=&#8221;javascript&#8221;&gt;<\/div>\n<div id=\"_mcePaste\">var mydate=new Date();<\/div>\n<div id=\"_mcePaste\">var today=mydate.getDay();<\/div>\n<div id=\"_mcePaste\">if (today==0){document.write(&#8216;Today is Sunday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: pink&#8221;&gt;&#8217;)};<\/div>\n<div id=\"_mcePaste\">else if (today==1){document.write(&#8216;Today is Monday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: blue&#8221;&gt;&#8217;)};<\/div>\n<div id=\"_mcePaste\">else if (today==2){document.write(&#8216;Today is Tuesday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: red&#8221;&gt;&#8217;)};<\/div>\n<div id=\"_mcePaste\">else if (today==3){ document.write(&#8216;Today is Wednesday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: green&#8221;&gt;&#8217;)};<\/div>\n<div id=\"_mcePaste\">else if (today==4){document.write(&#8216;Today is Thursday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: yellow&#8221;&gt;&#8217;)};<\/div>\n<div id=\"_mcePaste\">else if (today==5){document.write(&#8216;Today is Friday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: orange&#8221;&gt;&#8217;)};<\/div>\n<div id=\"_mcePaste\">else if(today==6){document.write(&#8216;Today is Saturday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: cyan&#8221;&gt;&#8217;)};<\/div>\n<div id=\"_mcePaste\">&lt;\/script&gt;<\/div>\n<p><script type=\"text\/javascript\">\/\/ <![CDATA[\nvar mydate=new Date();\n var today=mydate.getDay();\n\n if (today==0){document.write('Today is Sunday');document.write ('<body style=\"background-color: pink\">')};\n else if (today==1){document.write('Today is Monday');document.write ('<body style=\"background-color: blue\">')};\n else if (today==2){document.write('Today is Tuesday');document.write ('<body style=\"background-color: red\">')};\n else if (today==3){ document.write('Today is Wednesday');document.write ('<body style=\"background-color: green\">')};\n else if (today==4){document.write('Today is Thursday');document.write ('<body style=\"background-color: yellow\">')};\n else if (today==5){document.write('Today is Friday');document.write ('<body style=\"background-color: orange\">')};\n else if(today==6){document.write('Today is Saturday');document.write ('<body style=\"background-color: cyan\">')};\n\/\/ ]]><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is quite simple to change the background color of the webpage according to the days of a week. You can do this by using a series of ifs. The code is as follows, but it only works in Internet Explorer. &lt;script language=&#8221;javascript&#8221;&gt; var mydate=new Date(); var today=mydate.getDay(); if (today==0){document.write(&#8216;Today is Sunday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: pink&#8221;&gt;&#8217;)}; &hellip; <a href=\"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Changing color of webpage according to days of week&#8221;<\/span><\/a><\/p>\n","protected":false},"author":35895,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-207","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Changing color of webpage according to days of week - Learn JavaScript Online | Free Interactive JavaScript Tutorials<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Changing color of webpage according to days of week - Learn JavaScript Online | Free Interactive JavaScript Tutorials\" \/>\n<meta property=\"og:description\" content=\"It is quite simple to change the background color of the webpage according to the days of a week. You can do this by using a series of ifs. The code is as follows, but it only works in Internet Explorer. &lt;script language=&#8221;javascript&#8221;&gt; var mydate=new Date(); var today=mydate.getDay(); if (today==0){document.write(&#8216;Today is Sunday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: pink&#8221;&gt;&#8217;)}; &hellip; Continue reading &quot;Changing color of webpage according to days of week&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn JavaScript Online | Free Interactive JavaScript Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2011-09-14T15:38:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-12-25T16:33:11+00:00\" \/>\n<meta name=\"author\" content=\"Liew Voon Kiong\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Liew Voon Kiong\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/\",\"url\":\"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/\",\"name\":\"Changing color of webpage according to days of week - Learn JavaScript Online | Free Interactive JavaScript Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/javascript-tutor.net\/#website\"},\"datePublished\":\"2011-09-14T15:38:56+00:00\",\"dateModified\":\"2012-12-25T16:33:11+00:00\",\"author\":{\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8\"},\"breadcrumb\":{\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/javascript-tutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Changing color of webpage according to days of week\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/javascript-tutor.net\/#website\",\"url\":\"https:\/\/javascript-tutor.net\/\",\"name\":\"Learn JavaScript Online | Free Interactive JavaScript Tutorials\",\"description\":\"Master JavaScript with free, interactive tutorials for beginners and experienced coders. Practice live coding and visualize how JavaScript works step by step.\",\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8\",\"name\":\"Liew Voon Kiong\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g\",\"caption\":\"Liew Voon Kiong\"},\"url\":\"https:\/\/javascript-tutor.net\/index.php\/author\/ajt7051jct\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Changing color of webpage according to days of week - Learn JavaScript Online | Free Interactive JavaScript Tutorials","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/","og_locale":"en_US","og_type":"article","og_title":"Changing color of webpage according to days of week - Learn JavaScript Online | Free Interactive JavaScript Tutorials","og_description":"It is quite simple to change the background color of the webpage according to the days of a week. You can do this by using a series of ifs. The code is as follows, but it only works in Internet Explorer. &lt;script language=&#8221;javascript&#8221;&gt; var mydate=new Date(); var today=mydate.getDay(); if (today==0){document.write(&#8216;Today is Sunday&#8217;);document.write (&#8216;&lt;body style=&#8221;background-color: pink&#8221;&gt;&#8217;)}; &hellip; Continue reading \"Changing color of webpage according to days of week\"","og_url":"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/","og_site_name":"Learn JavaScript Online | Free Interactive JavaScript Tutorials","article_published_time":"2011-09-14T15:38:56+00:00","article_modified_time":"2012-12-25T16:33:11+00:00","author":"Liew Voon Kiong","twitter_misc":{"Written by":"Liew Voon Kiong","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/","url":"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/","name":"Changing color of webpage according to days of week - Learn JavaScript Online | Free Interactive JavaScript Tutorials","isPartOf":{"@id":"https:\/\/javascript-tutor.net\/#website"},"datePublished":"2011-09-14T15:38:56+00:00","dateModified":"2012-12-25T16:33:11+00:00","author":{"@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8"},"breadcrumb":{"@id":"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/javascript-tutor.net\/index.php\/2011\/09\/14\/changing-color-webpage-days-week\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/javascript-tutor.net\/"},{"@type":"ListItem","position":2,"name":"Changing color of webpage according to days of week"}]},{"@type":"WebSite","@id":"https:\/\/javascript-tutor.net\/#website","url":"https:\/\/javascript-tutor.net\/","name":"Learn JavaScript Online | Free Interactive JavaScript Tutorials","description":"Master JavaScript with free, interactive tutorials for beginners and experienced coders. Practice live coding and visualize how JavaScript works step by step.","inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8","name":"Liew Voon Kiong","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g","caption":"Liew Voon Kiong"},"url":"https:\/\/javascript-tutor.net\/index.php\/author\/ajt7051jct\/"}]}},"_links":{"self":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/users\/35895"}],"replies":[{"embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":5,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":541,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/207\/revisions\/541"}],"wp:attachment":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}