Please help me i have been working on this code for a few days and cant figure it out. for some reason i am getting a broken graphic on the computer tab and i cant figure out why. Also i cant figure out how to get the side menu to disappear after i have clicked on the body of the menu or on anotehr one of the tabbed menus. the only error i get when i view it in IE is the message below. Any help would be greatly appreciated. Let me know if you need any other information.
Message: 'activeMenu.style' is null or not an object
Line: 79
Char: 1
Code: 0
<html>
<head>
<title>Jackson Electronics Printers</title>
<link href="je.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript">
if(document.images){
image = new Array();
image[1]="main1.jpg";
image[2]="main2.jpg";
image[3]="main3.jpg";
image[4]="main4.jpg";
image[5]="main5.jpg";
image[6]="main6.jpg";
image[1].src="main1.jpg";
image[2].src="main2.jpg";
image[3].src="main3.jpg";
image[4].src="main4.jpg";
image[5].src="main5.jpg";
image[6].src="main6.jpg";
imageOver = new Array();
imageOver[1]="main1_over.jpg";
imageOver[2]="main2_over.jpg";
imageOver[3]="main3_over.jpg";
imageOver[4]="main4_over.jpg";
imageOver[5]="main5_over.jpg";
imageOver[6]="main6_over.jpg";
imageOver[1].src="main1_over.jpg";
imageOver[2].src="main2_over.jpg";
imageOver[3].src="main3_over.jpg";
imageOver[4].src="main4_over.jpg";
imageOver[5].src="main5_over.jpg";
imageOver[6].src="main6_over.jpg";
image[i] = new Image;
imageOver[i] = new Image;
image[i].src="main" + i + ".jpg";
imageOver[i].src="main" + i + "_over.jpg";
}
for (var i=1; i <=6; i++){
var maxZ=6; // this variable stores the z-index of the currently displayed menu in the tabbed menu system.
var activeMenu = null; //this varialbe stores the submenu currenlty displayed in the sliding menu.
}
function swapIn(num){
if (document.images) document.images[num].src=imageOver[num].src;
}
function swapOut(num){
if (document.images) document.images[num].src=image[num].src;
}
function showMain(num){
maxZ++;
document.getElementById("mainMenu"+num).style.zIndex=maxZ;
}
function hideActive(){
activeMenu.style.left="10px";
}
function slideMenu(){
var x=xCoord();
if (x <= 126){
shiftMenu(2,0);
setTimeout("slideMenu()",10);
}
}
function startSlide(num){
if (activeMenu !==null)
hideActive();
activeMenu = document.getElementById("sideMenu"+num);
slideMenu();
;
}
</script>
<script type="text/JavaScript">
function xCoord() {
return parseInt(activeMenu.style.left);
}
function shiftMenu(dx, dy) {
xc=parseInt(activeMenu.style.left);
yc=parseInt(activeMenu.style.top);
activeMenu.style.left=xc+dx+"px";
activeMenu.style.top=yc+dy+"px";
}
/*
In the tabbed menu titles section i changed the href attritbute of the inline image from "#" to a link that calls the showMain() function using 1 as the parameter value. I also added an onmouseover event handler to emain1.jpg inline image to run the swapIn() function, using 1 as a parameter. I also added onmouseover event handler to the main1.jpg inline mimage so run the swapOut() funciton also using 1 as a parameter. I repeated these steps for images 1-6.
Within the hotspot for the first area element i changed the href attribute from "#" to a link that calls the startSlide() function using 1 as a parameter value. This is reapeated throught all images 1-6.
*/
<!-- Page Content -->
<div id="main" onClick="hideActive()">
<h1>Printers</h1>
<img src="printer.jpg" alt="" />
<p>The best photo prints can now be made ... AT HOME. Introducing the Jackson
Electronics' <b>Picture Perfect</b> printer. Darkroom quality prints
without the cost, the mess, or the dark.</p>
<p>Photo Shopper calls JE's Picture Perfect "<i>the photo printer
we've been waiting for: high quality prints at an affordable price.</i>"
Photo Review gives it 5 stars, calling it <i>"the outstanding product
of the year."</i> As with all of our printers, make sure to choose JE's
archival quality paper and inks, which are guaranteed not to fade.
There is no better way to preserve your family memories than with
JE photo products.</p>
<p><a href="#">Order</a> the award-winning <b>Picture Perfect</b> printer
today for the special price of <b>$299.95</b> or choose one of the other many
fine printer products from Jackson Electronics.</p>
</div>
can you provide me with a little more detail than that
could you elaborate a little please? when i pull up IE i am only getting the null error. i am also using a javascript debugger that is showing no javascript errors.
could you elaborate a little please? when i pull up IE i am only getting the null error. i am also using a javascript debugger that is showing no javascript errors.
hideActive is called from several places, without testing that activeMenu is defined.
Code:
function startSlide(num){
if (activeMenu !==null)
hideActive();
activeMenu = document.getElementById("sideMenu"+num);
slideMenu();
;
}
That test is incorrect because null !== undefined.
Code:
if( typeof activeMenu === 'undefined' )
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
how can it be referenced before i declare it as null when it is shown before any of my functions? Do i need to put my variables above my original if statement?
Bookmarks