Completing the HTML Magic Edges Project
(Page 1 of 5 )
Welcome to the fifth part of a five-part series that shows you how to make HTML magic edges. These edges allow you to slide useful applications out of the sides of your web pages when a visitor slides his or her mouse over the edges. In this part of the series I explain the code for the project. We also conclude with some useful comments. Toward the end of this part, I give you a link to the complete code of the project in zip file format.
The Code and its Operation
I will give you the code as it is found in the zip file from top to bottom. I will be brief in the explanation, since we've covered the basics in the previous parts. We begin with the global variables that are used in many sections of the code. These variables are:
var edge = "";
var paneBack = true;
var leftPaneShown = false;
var topPaneShown = false;
These variables are related to some of the technical requirements we saw in the third part of the series. When the pane has scrolled from the left edge into the page, this edge variable is given the value “left.” When the pane has scrolled from the top down into the page, the variable is given the value “top.”
When the pane is still in the edge or has gone back into the edge, the paneBack variable is used to indicate this with the value of true.
Now, when you click the BODY element, the pane should scroll away. When you click the pane, since the pane is in front of the BODY element, the BODY indirectly receives a click. You do not want the pane to scroll back when the BODY is not clicked directly. The next two variables above are used for this. The first one (leftPaneShown) is for the pane from the left edge. The second one (topPaneShown) is for the pane from the top edge.
Left Edge Code
In this section we shall talk about the code for the left mimic edge.
The giveHeight() Function
Ideally the left mimic edge should be as long as the entire height of the web page. It is not a straightforward task to achieve this height. We shall allow a simple design. The DOM can allow us to get the height of the screen (without the portion of the taskbar). We shall use this height for the left mimic edge. When the page is just loaded, the giveHeight() function is called by the onload event of the BODY attribute. The function gives the height. This is the function:
function giveHeight()
{
document.getElementById('DL').style.height = screen.availHeight;
}
Next: Code to Shift Right and Left >>
More HTML Articles
More By Chrysanthus Forcha