Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6637777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:21:17+00:00 2026-05-25T23:21:17+00:00

I was reading a program to make sliding menus. Though the program works fine,there

  • 0

I was reading a program to make sliding menus. Though the program works fine,there are certain things for which i don’t have a clue what do they mean and what are they doing.

HTML

<html>
<head>
<title>Shakespeare's Plays</title>
<link rel="stylesheet" href="script.css" />
<script type="text/javascript" src="script.js">
</script>
</head>
<body>
<h1>Shakespeare's Plays</h1>
<div>
    <a href="menu1.html" class="menuLink">Comedies</a>
    <ul class="menu" id="menu1">
        <li><a href="pg1.html">All's Well That Ends Well</a></li>
        <li><a href="pg2.html">As You Like It</a></li>
    </ul>
</div>
<div>
    <a href="menu2.html" class="menuLink">Tragedies</a>
    <ul class="menu" id="menu2">
        <li><a href="pg5.html">Anthony &amp; Cleopatra</a></li>
        <li><a href="pg6.html">Hamlet</a></li>
    </ul>
</div>
<div>
    <a href="menu3.html" class="menuLink">Histories</a>
    <ul class="menu" id="menu3">
        <li><a href="pg8.html">Henry IV, Part 1</a></li>
        <li><a href="pg9.html">Henry IV, Part 2</a></li>
    </ul>
</div>
 </body>
 </html>

CSS

body {
background-color: white;
color: black;
}

div {
padding-bottom: 10px;
background-color: #6FF;
width: 220px;
}

ul.menu {
display: none;
list-style-type: none;
margin-top: 5px;
}

a.menuLink {
font-size: 16px;
font-weight: bold;
}

a {
text-decoration: none;
}

Java Script

window.onload = initAll;

function initAll() {
var allLinks = document.getElementsByTagName("a");

for (var i=0; i<allLinks.length; i++) {
    if (allLinks[i].className.indexOf("menuLink") > -1) {
        allLinks[i].onclick = toggleMenu;
    }
}
}

function toggleMenu() {
var startMenu = this.href.lastIndexOf("/")+1;
var stopMenu = this.href.lastIndexOf(".");
var thisMenuName = this.href.substring(startMenu,stopMenu);

var thisMenu = document.getElementById(thisMenuName).style;
if (thisMenu.display == "block")  {
    thisMenu.display = "none";
}
else {
    thisMenu.display = "block";
}

return false;
}

In the javascript code:

  1. what do these 2 statements do ?

    var startMenu = this.href.lastIndexOf("/")+1;
        var stopMenu = this.href.lastIndexOf(".");
    
  2. what does this.href mean . I know that this refers to the link but what does href denote ?
  3. what does the statement thisMenu.display == "block" mean ? I mean to say what is display and what is block . The code does not declare it anywhere.
  4. In the same way what is meant by none ?
  5. What does the statement document.getElementById(thisMenuName).style return ?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:21:18+00:00Added an answer on May 25, 2026 at 11:21 pm
    1. what do these 2 statements do ?
    
    var startMenu = this.href.lastIndexOf("/")+1;
        var stopMenu = this.href.lastIndexOf(".");
    

    That code is within the toggleMenu function that is assigned to an onclick listener of link elements (they are probably the items in your menu). When the function is called by the onclick handler, the function’s this keyword is set to a reference to the element (i.e. the link). So the first line is getting the position of the last ‘/’ in the href property, the second is getting the index of the last “.” in the href.

    2. what does this.href mean . I know that this refers to the link but
    

    what does href denote ?

    It is a refernce to the link’s href property, which is initially set to the value of the href attribute.

    3. what does the statement thisMenu.display == "block" mean ? I mean
    

    to say what is display and what is block . The code does not declare
    it anywhere.

    It is changing the value of the display property of the element’s style object to “block”, which is one value that it may have according to the CSS 2.1 specification. A better strategy is to set the display property in CSS (or just use the default) and in code set it to “” (empty string) so that it adopts the default or cascaded style (which can be any one of 13 values and might be different in different browsers so setting it specifically can be an issue).

    That way the layout and display are independent of the code, which just hides it or returns it to whatever it was.

    4. In the same way what is meant by none ?
    

    That makes the element not part of the document flow, effectively hiding it and meaning it doesn’t have any effect on the document layout.

    5. What does the statement document.getElementById(thisMenuName).style return ?
    

    It returns a reference to the element’s style object, it’s used to make the code more concise (and likely a tad faster, not that you’d notice here).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a program in java in which one thread is reading
I'm trying to make fdisk program in Linux. I have a buffer which contains
I have a java program in which I am reading from stdin BufferedInputStream bis
I have a larger C++ program which starts out by reading thousands of small
I'm reading about program specialization - specifically java and I don't think I quite
I have a C++ program that is reading in info from a file, that
I have a simple RabbitMQ test program randomly enqueuing messages, and another reading them,
I have a program reading from a text file (currently 653 lines long) all
So I'm reading in a file (like java program < trace.dat) which looks something
I'm trying to make a program which Takes the user input (let's say all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.