{"id":54296,"date":"2021-12-17T03:01:39","date_gmt":"2021-12-16T17:01:39","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=54296"},"modified":"2021-12-17T18:09:02","modified_gmt":"2021-12-17T08:09:02","slug":"sprite-background-menu-navigation-javascript-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/sprite-background-menu-navigation-javascript-tutorial\/","title":{"rendered":"Sprite Background Menu Navigation Javascript Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Sprite Background Menu Navigation Javascript Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.jpg\" title=\"Sprite Background Menu Navigation Javascript Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Sprite Background Menu Navigation Javascript Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <a title='Sprite Background Menu Navigation Primer Tutorial' href='#sbmnpt'>Sprite Background Menu Navigation Primer Tutorial<\/a> set the scenario for today&#8217;s work, that we are often looking for.  You see, we&#8217;re trying to help beginners to web application creation here, by and large, and there is no better topic to learn about than &#8230; <a target=_blank title='?' href='https:\/\/www.youtube.com\/watch?v=uhiCFdWeQfA'>anyone, anyone<\/a>?  Yes, <a target=_blank href='https:\/\/en.wikipedia.org\/wiki\/Brendan_Eich' title='?'>Brendan<\/a>, the working knowledge of Javascript, as the prominent <a target=_blank title='?' href='https:\/\/www.youtube.com\/watch?v=uhiCFdWeQfA'>anyone, anyone<\/a>?  <font size=1>Semi-pending-<\/font>yes, <a target=_blank href='https:\/\/en.wikipedia.org\/wiki\/Matt_Mullenweg'><font size=1>semi-<\/font>snaps for you if you mean<\/a> <a target=_blank title='theme' href='https:\/\/www.google.com\/search?q=theme&#038;rlz=1C5CHFA_enAU973AU973&#038;oq=theme&#038;aqs=chrome..69i57j0i67j0i20i263i512j0i512l3j69i60j69i61.1343j0j4&#038;sourceid=chrome&#038;ie=UTF-8'>theme<\/a> and not <a target=_blank title='theme' href='https:\/\/www.codeinwp.com\/blog\/default-wordpress-themes\/'>theme<\/a> if you know what I <strike><a target=_blank title='meme' href='https:\/\/en.wikipedia.org\/wiki\/Meme'>meme<\/a><\/strike>mean <font size=1>(chortle, chortle)<\/font>!<\/p>\n<p>Yes, beginners to this &#8220;web application caper&#8221; should learn &#8230;<\/p>\n<ul>\n<li>HTML (design) &#8230; to show something &#8230; perhaps the first thing to learn &#8230; and &#8230;<\/li>\n<li>Javascript (programming) &#8230; to have interactions of interest in that webpage above &#8230; the major &#8220;clientside&#8221; thing to learn &#8230; otherwise can be a bit boring &#8230; though there is also &#8230;<\/li>\n<li>CSS (styling) &#8230; to control the look of the creation &#8230; the &#8220;show your friends&#8221; &#8220;clientside&#8221; thing to learn &#8230; though we have done <a target=_blank title='Missing Javascript' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/?s=missing%20Javascript'>&#8220;no Javascript&#8221;<\/a> tutorials in the past<\/li>\n<\/ul>\n<p> &#8230; but we would say that middle one is your topic to concentrate on throughout your learning.<\/p>\n<p>Add to that, down the track, by adding to those &#8220;clientside&#8221; scenarios above, a &#8220;serverside&#8221; programming skill, such as <a target=_blank title='PHP' href='https:\/\/www.php.net\/'>PHP<\/a> programming (for our Apache\/PHP\/MySql favourite local web browser via <a target=_blank title='MAMP for Apache\/PHP\/MySql on Mac OS X local web server' href='http:\/\/www.mamp.info'>MAMP<\/a>, scenarios).<\/p>\n<p>And so with yesterday&#8217;s <a title='Sprite Background Menu Navigation Primer Tutorial' href='#sbmnpt'>Sprite Background Menu Navigation Primer Tutorial<\/a> all of us got you to a <a target=_blank title='Missing Javascript' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/?s=missing%20Javascript'>&#8220;no Javascript&#8221;<\/a> start on the <a target=_blank title='https:\/\/www.tutorialrepublic.com\/css-tutorial\/css-sprites.php' href='\/\/www.tutorialrepublic.com\/css-tutorial\/css-sprites.php'>CSS Sprites<\/a> <strike><a target=_blank title='meme' href='https:\/\/en.wikipedia.org\/wiki\/Meme'>meme<\/a><\/strike><a target=_blank title='theme' href='https:\/\/www.google.com\/search?q=theme&#038;rlz=1C5CHFA_enAU973AU973&#038;oq=theme&#038;aqs=chrome..69i57j0i67j0i20i263i512j0i512l3j69i60j69i61.1343j0j4&#038;sourceid=chrome&#038;ie=UTF-8'>theme<\/a>.  Today we stage some Javascript &#8220;easing in to learning&#8221; <strike><a target=_blank title='meme' href='https:\/\/en.wikipedia.org\/wiki\/Meme'>meme<\/a><\/strike><a target=_blank title='theme' href='https:\/\/www.google.com\/search?q=theme&#038;rlz=1C5CHFA_enAU973AU973&#038;oq=theme&#038;aqs=chrome..69i57j0i67j0i20i263i512j0i512l3j69i60j69i61.1343j0j4&#038;sourceid=chrome&#038;ie=UTF-8'>theme<\/a>s &#8230;<\/p>\n<table>\n<tr>\n<th>Javascript idea &#8230;<\/th>\n<th>HTML\/Javascript coding change<\/th>\n<\/tr>\n<tr>\n<td style='vertical-align:top;'><a target=_blank title='Navigations to a new tab' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html-GETME'>Navigations to a new tab<\/a> <br \/><font size=1>(if, like here&#8217;, embedded <a href='#sprite_eg_iframe' title='down'>within an HTML iframe element<\/a> <a href='#pcode' title='Within iframe test Javascript code'><b><\/i>*<\/i><\/a><\/b><\/a>)<\/font><\/td>\n<td style='vertical-align:top;'><iframe onload=\"this.contentWindow.scrollTo(0,450);\" style=\"transform:scale(0.8);width:500px;height:900px;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html-GETME\"><\/iframe><\/td>\n<\/tr>\n<tr>\n<td style='vertical-align:top;'><a target=_blank title='Navigations even via image clicks' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html--GETME'>Navigations even via image clicks<\/a><\/td>\n<td style='vertical-align:top;'><iframe onload=\"this.contentWindow.scrollTo(0,450);\"  style=\"transform:scale(0.8);width:500px;height:900px;\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html--GETME\"><\/iframe><\/td>\n<\/tr>\n<\/table>\n<p id=pcode><b><\/i>*<\/i><\/b>  &#8230;<br \/>\n<code><br \/>\n&lt;script type='text\/javascript'&gt;<br \/>\n function inIframe() {  \/\/ thanks to https:\/\/stackoverflow.com\/questions\/326069\/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t<br \/>\n    try {<br \/>\n        return window.self !== window.top;<br \/>\n    } catch (e) {<br \/>\n        return true;<br \/>\n    }<br \/>\n }<br \/>\n&lt;\/script&gt;<br \/>\n<\/code>\n<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank href='\/\/www.rjmprogramming.com.au\/ITblog\/sprite-background-menu-navigation-javascript-tutorial\/'>Sprite Background Menu Navigation Javascript Tutorial<\/a>.<\/p-->\n<hr>\n<p id='sbmnpt'>Previous relevant <a target=_blank title='Sprite Background Menu Navigation Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/sprite-background-menu-navigation-primer-tutorial\/'>Sprite Background Menu Navigation Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Sprite Background Menu Navigation Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.gif\" title=\"Sprite Background Menu Navigation Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Sprite Background Menu Navigation Primer Tutorial<\/p><\/div>\n<p>There are a lot of ways to design and code for a menu used for navigation in a webpage.  We happened to be reading <a target=_blank title='https:\/\/www.tutorialrepublic.com\/css-tutorial\/css-sprites.php' href='\/\/www.tutorialrepublic.com\/css-tutorial\/css-sprites.php'>CSS Sprites<\/a>, and where it said &#8230;<\/p>\n<blockquote cite='\/\/www.tutorialrepublic.com\/css-tutorial\/css-sprites.php'><p>\nCSS sprites technique is a way to reduce the number of HTTP requests made for image resources, by combining images in a single file.\n<\/p><\/blockquote>\n<p> &#8230; and its great menu navigation example (which forms a huge part of our <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html_GETME\">sprite_eg.html<\/a>&#8216;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html\">live run<\/a> link), we wanted to use it to adapt it with inhouse content.  That content is the Sprite image we constructed with a combination of &#8230;<\/p>\n<ul>\n<li><a target=_blank title='Google image search' href='https:\/\/www.google.com\/search?q=rjmprogramming&#038;tbm=isch&#038;hl=en&#038;chips=q:rjmprogramming,online_chips:javascript&#038;sa=X&#038;ved=2ahUKEwiT19P2iuP0AhV4jNgFHWsyA7wQ4lYoB3oECAEQIA&#038;biw=1440&#038;bih=738'>some inhouse images<\/a> via a Google image search, thanks<\/li>\n<li>in macOS command-control-shift-3 to <a target=_blank title='macOS PaintBrush' href='https:\/\/paintbrush.sourceforge.io\/'>Paintbrush<\/a> File-&gt;New from Clipboard to huhagain.png (internal use only)<\/li>\n<li>in macOS Paintbrush File-&gt;New 50 pixels x 500 pixels saved to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/newSprite.png\">newSprite.png <!--img src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/newSprite.png\"><\/img--><\/a> &#8230; though at this early stage imagine it all white &#8230;<\/li>\n<table>\n<tr>\n<th colspan=5>For 5 image choices<\/th>\n<\/tr>\n<tr>\n<th>oneinfive.png<\/th>\n<th>twoinfive.png<\/th>\n<th>threeinfive.png<\/th>\n<th>fourinfive.png<\/th>\n<th>fiveinfive.png<\/th>\n<\/tr>\n<tr>\n<td>\nRectangular select from huhagain.png relevant bit<br \/>\nFile-&gt;New from Clipboard<br \/>Image-&gt;Image Size&#8230; 50 pixels x 50pixels<br \/>\nFile-&gt;Save As&#8230; oneinfive.jpg<br \/>\nEdit-&gt;Select All<br \/>\nEdit-&gt;Copy<\/p>\n<p>#Reopen Paintbrush huhagain.png<br \/>\nEdit-&gt;Paste<br \/>\nDrag to whitespace slot that is free &#8230;<\/p>\n<p>In terminal (with <a target=_blank title='ImageMagick' href='http:\/\/www.imagemagick.org'>ImageMagick<\/a> installed) &#8230;<br \/>\n$ convert oneinfive.png -channel RGB -negate onefive.jpg<\/p>\n<p>Open Paintbrush onefive.jpg<br \/>\nEdit-&gt;Select All<br \/>\nEdit-&gt;Copy<\/p>\n<p>#Reopen Paintbrush huhagain.png<br \/>\nEdit-&gt;Paste<br \/>\nDrag to whitespace slot that is free\n<\/td>\n<td>As far left <br \/>substitute &#8220;one&#8221; for &#8220;two&#8221;<\/td>\n<td>As far left <br \/>substitute &#8220;one&#8221; for &#8220;three&#8221;<\/td>\n<td>As far left <br \/>substitute &#8220;one&#8221; for &#8220;four&#8221;<\/td>\n<td>As far left <br \/>substitute &#8220;one&#8221; for &#8220;five&#8221;<\/td>\n<\/tr>\n<\/table>\n<\/li>\n<tr>\n<th colspan=5>#Reopen Paintbrush huhagain.png and File-&gt;SaveAs&#8230; <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/newSprite.png\">newSprite.png  <img decoding=\"async\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/newSprite.png\"><\/img><\/a><\/th>\n<\/tr>\n<\/ul>\n<p> &#8230; to end up with the originals and negated &#8220;onhover flip sided&#8221; colour negations (or inversion) Sprite image backgrounds to the menu imagery.  We hope it interests!<\/p>\n<p><iframe id=sprite_eg_iframe src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sprite_eg.html\" style=\"width:100%;height:600px;\"><\/iframe><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d54279' onclick='var dv=document.getElementById(\"d54279\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/paintbrush\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d54279' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d54296' onclick='var dv=document.getElementById(\"d54296\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/javascript\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d54296' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday&#8217;s Sprite Background Menu Navigation Primer Tutorial set the scenario for today&#8217;s work, that we are often looking for. You see, we&#8217;re trying to help beginners to web application creation here, by and large, and there is no better topic &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/sprite-background-menu-navigation-javascript-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[126,2471,265,281,2237,400,576,587,590,1658,770,3876,830,3877,861,870,896,907,997,2173,1209,1212,1319,1418,1583],"class_list":["post-54296","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-background","tag-background-position","tag-copy","tag-css","tag-drag","tag-event","tag-html","tag-iframe","tag-image","tag-imagemagick","tag-menu","tag-missing-javascript","tag-navigation","tag-new-tab","tag-onclick","tag-onload","tag-paintbrush","tag-paste","tag-programming","tag-sprite","tag-style","tag-styling","tag-tutorial","tag-webpage","tag-window"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/54296"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=54296"}],"version-history":[{"count":30,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/54296\/revisions"}],"predecessor-version":[{"id":54344,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/54296\/revisions\/54344"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=54296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=54296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=54296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}