Sprite Background Menu Navigation Javascript Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Sprite Background Menu Navigation Javascript Tutorial

Sprite Background Menu Navigation Javascript Tutorial

Yesterdayโ€™s Sprite Background Menu Navigation Primer Tutorial set the scenario for todayโ€™s work, that we are often looking for. You see, weโ€™re trying to help beginners to web application creation here, by and large, and there is no better topic to learn about than โ€ฆ anyone, anyone? Yes, Brendan, the working knowledge of Javascript, as the prominent anyone, anyone? Semi-pending-yes, semi-snaps for you if you mean theme and not theme if you know what I mememean (chortle, chortle)!

Yes, beginners to this โ€œweb application caperโ€ should learn โ€ฆ

  • HTML (design) โ€ฆ to show something โ€ฆ perhaps the first thing to learn โ€ฆ and โ€ฆ
  • Javascript (programming) โ€ฆ to have interactions of interest in that webpage above โ€ฆ the major โ€œclientsideโ€ thing to learn โ€ฆ otherwise can be a bit boring โ€ฆ though there is also โ€ฆ
  • CSS (styling) โ€ฆ to control the look of the creation โ€ฆ the โ€œshow your friendsโ€ โ€œclientsideโ€ thing to learn โ€ฆ though we have done โ€œno Javascriptโ€ tutorials in the past

โ€ฆ but we would say that middle one is your topic to concentrate on throughout your learning.

Add to that, down the track, by adding to those โ€œclientsideโ€ scenarios above, a โ€œserversideโ€ programming skill, such as PHP programming (for our Apache/PHP/MySql favourite local web browser via MAMP, scenarios).

And so with yesterdayโ€™s Sprite Background Menu Navigation Primer Tutorial all of us got you to a โ€œno Javascriptโ€ start on the CSS Sprites memetheme. Today we stage some Javascript โ€œeasing in to learningโ€ memethemes โ€ฆ

Javascript idea โ€ฆ HTML/Javascript coding change
Navigationsโšชto a new tab
(if, like hereโ€™, embedded within an HTML iframe element *)
Navigationsโšชeven via image clicks

* โ€ฆ


<script type='text/javascript'>

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

try {

return window.self !== window.top;

} catch (e) {

return true;

}

}

</script>



Previous relevant Sprite Background Menu Navigation Primer Tutorial is shown below.

Sprite Background Menu Navigation Primer Tutorial

Sprite Background Menu Navigation Primer Tutorial

There are a lot of ways to design and code for a menu used for navigation in a webpage. We happened to be reading CSS Sprites, and where it said โ€ฆ

CSS sprites technique is a way to reduce the number of HTTP requests made for image resources, by combining images in a single file.

โ€ฆ and its great menu navigation example (which forms a huge part of our sprite_egโšซhtmlโ€˜s liveโœ‚run link), we wanted to use it to adapt it with inhouse content. That content is the Sprite image we constructed with a combination of โ€ฆ

  • some inhouse images via a Google image search, thanks
  • in macOS command-control-shift-3 to Paintbrush File->New from Clipboard to huhagain.png (internal use only)
  • in macOS Paintbrush File->New 50 pixels x 500 pixels saved to newSprite.png โ€ฆ though at this early stage imagine it all white โ€ฆ
  • For 5 image choices
    oneinfive.png twoinfive.png threeinfive.png fourinfive.png fiveinfive.png
    Rectangular select from huhagain.png relevant bit
    File->New from Clipboard
    Image->Image Sizeโ€ฆ 50 pixels x 50pixels
    File->Save Asโ€ฆ oneinfive.jpg
    Edit->Select All
    Edit->Copy

    #Reopen Paintbrush huhagain.png
    Edit->Paste
    Drag to whitespace slot that is free โ€ฆ

    In terminal (with ImageMagick installed) โ€ฆ
    $ convert oneinfive.png -channel RGB -negate onefive.jpg

    Open Paintbrush onefive.jpg
    Edit->Select All
    Edit->Copy

    #Reopen Paintbrush huhagain.png
    Edit->Paste
    Drag to whitespace slot that is free

    As far left
    substitute โ€œoneโ€ for โ€œtwoโ€
    As far left
    substitute โ€œoneโ€ for โ€œthreeโ€
    As far left
    substitute โ€œoneโ€ for โ€œfourโ€
    As far left
    substitute โ€œoneโ€ for โ€œfiveโ€
    #Reopen Paintbrush huhagain.png and File->SaveAsโ€ฆ newSprite.png

โ€ฆ to end up with the originals and negated โ€œonhover flip sidedโ€ colour negations (or inversion) Sprite image backgrounds to the menu imagery. We hope it interests!

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *