PDA

View Full Version : Runtime Error with script xpmenuv21.js



Aravona
01-12-2010, 11:57 AM
1) Script Title: xpmenuv21.js

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/switchmenu2.htm#

3) Describe problem:

Having problems with internet explorer running a file (xpmenuv21.js) it was working fine before I had to transfer a site from one server to another. It is running, albeit not as well as it was, in Fire Fox.

As I load pages on the new site in Internet explorer I get the following error:


Runtime error
Line: 245
Error menuObjArray[0][i].filters.alpha is null or not an object

Line 245 in the file is:


menuObjArray[0][i].filters.alpha.opacity = 0;

I'm not very good with javascript so any help would be appriciated.

jscheuer1
01-12-2010, 04:11 PM
That would tend to indicate that your copy of IE has filters unavailable or that you missed something in the installation of the script.

If I had a link to your page, I could probably tell which:

Please post a link to the page on your site that contains the problematic code so we can check it out.

Regardless, a try/catch could probably eliminate the error if its application to the existing code were well thought out, and get the code to work albeit without any fade effects for that line's object.

But it might just be a matter of installation, in which case that should be cleared up first.

Aravona
01-12-2010, 04:35 PM
1) Script Title: xpmenuv21.js

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/switchmenu2.htm (I think its this one, like I said I didnt choose the code in the first place)

http://www.leisure-shop-online.com/test/

Thats the site.

I was not the person to put this on the website, I'm just picking up where they left off (and I don't even know who they are)

The code is working currently on FireFox only, but it used to work fine (before transfer to a new server) on both Internet Explorer and FireFox.

jscheuer1
01-12-2010, 05:22 PM
There could be other problems but your:


<link rel="stylesheet" href="js/sddm.css" type="text/css" media="screen" id="st2" />

is apparently to an empty file:


http://www.leisure-shop-online.com/test/js/sddm.css

It may actually be a 404 not found (missing), or even something else, that would depend upon how the server is setup. But it looks to be an empty file. It's contents should be more like so, the actual file from the old server would be better if it had been altered from the original (shown below) that comes with this script:


.navbar
{
}

.mainDiv
{
width:185px;
}

.topItem
{
font: bold 12px tahoma,verdana,sans-serif;
letter-spacing: 0;
background: url("arrow-up-title.jpg") no-repeat 0 0;
background-position:center center;
background-repeat:no-repeat;
border: none;
width: 185px;
height: 25px;
color: #215dc6;
cursor:pointer;
text-indent:10px;
}

.topItemOver
{
text-indent:10px;
font: bold 12px tahoma,verdana,sans-serif;
letter-spacing: 0;
background: url("arrow-up-title-on.jpg") no-repeat 0 0;
background-position:center center;
background-repeat:no-repeat;
height: 25px;
width: 185px;
color: #428eff;
cursor:pointer;
}

.topItemClose
{
text-indent:10px;
font: bold 12px tahoma,verdana,sans-serif;
letter-spacing: 0;
background: url("arrow-down-title.jpg") no-repeat 0 0;
background-position:center center;
background-repeat:no-repeat;
height: 25px;
width: 185px;
color: #215dc6;
cursor:pointer;
}


.topItemCloseOver
{
text-indent:10px;
font: bold 12px tahoma,verdana,sans-serif;
letter-spacing: 0;
background: url("arrow-down-title-on.jpg") no-repeat 0 0;
background-position:center center;
background-repeat:no-repeat;
height: 25px;
width: 185px;
color: #428eff;
cursor:pointer;
}



.dropMenu
{
font: bold 11px tahoma,verdana,sans-serif;
background-color: #d6dff7;
color: #000;
border: 1px solid #FFFFFF;
border-width: 0 1px 1px 1px;
filter:alpha(opacity=100);
padding-top:5px;
padding-bottom:5px;
}

.subMenu
{
display:block;
}

.subItem
{
margin-left:10px;
margin-top:2px;
height:18px;
font: 11px tahoma,verdana,sans-serif;
text-decoration:none;
color: #215dc6;

}

.subItem a
{
margin-left:23px;
font: 11px tahoma,verdana,sans-serif;
text-decoration:none;
color: #215dc6;
}

.subItemOver
{
margin-left:10px;
margin-top:2px;
font: 11px tahoma,verdana,sans-serif;
height:18px;
color: #428eff;
}

.subItemOver a
{
margin-left:23px;
font: 11px tahoma,verdana,sans-serif;
cursor:pointer;
color: #428eff;
text-decoration:underline;
cursor:pointer;
}


.drop
{
border-left:1px solid black;
border-right:1px solid black;
}



Without the filter for the .dropMenu class as declared in it, IE will give that error.

Aravona
01-13-2010, 09:07 AM
Thanks for your reply! The file was actually empty on the old server as well but we did have a malicious attack on the server and some of the files got corrupt. I will try adding this code in and see if that makes the drop down work. I will let you know if this works or not. Thanks again for helping.

EDIT: Thanks very much this code got the drop down working - but with one error I can't get a notification for. The colours etc are completely off but thats fine I can fix that. Thank you kindly!

Aravona
01-13-2010, 10:54 AM
I'm now getting a second error, which I didn't notice on the other computer as I dont get javascript notifications (I just got the usual 'done but with errors' no explanation)

The new error says:

line 206:
error: exception occured

this is line 206:

tmpStr2 = String("." + itemContainerDiv.childNodes.item(lastmenuNum).className);

jscheuer1
01-13-2010, 03:30 PM
I'm not getting that error. I'm getting these two:


Error: ddsmoothmenu is not defined
Source File: http://www.leisure-shop-online.com/test/
Line: 18

which refers to the fact that:


<script type="text/javascript" src="ddsmoothmenu.js">

which points to:


http://www.leisure-shop-online.com/test/ddsmoothmenu.js

is a 404 not found. And:


Error: document.styleSheets[r] is undefined
Source File: http://www.leisure-shop-online.com/test/js/xpmenuv21.js
Line: 157

which is probably because the sddm.css file is no longer linked to the page. This stylesheet (even if empty) must be linked to the page.

Aravona
01-13-2010, 03:48 PM
Sorry thats wrong now, I've already posted up a new problem as I've had to change the navagation I'm using. So I've removed the old script and am trying (and failing) to put this new one in.


http://www.dynamicdrive.com/forums/showthread.php?t=51603

jscheuer1
01-13-2010, 04:14 PM
My remarks as of this typing still apply to that page, mostly. If you are no longer using xpmenuv21.js, remove the script, it's causing an error. If you are using Smooth Navigational Menu (v1.31), ddsmoothmenu.js must be available to the page.

Aravona
01-13-2010, 04:29 PM
I had a mistake with my index page where i wasnt referencing the .js file path properly. Its correct now however I'm still not getting the side-out part of the menu.

The new javascript isnt in the same place as the old one and as far as I can tell I've removed the links to it.

jscheuer1
01-13-2010, 04:35 PM
The page linked to in this thread and in your new thread as the page you are working on are the same and have (as described above) the old script, but not the new one. What page are you actually working on at this point?

Aravona
01-13-2010, 04:42 PM
I have two pages, index.php which hold my javascript references, and menu.php which creates the side navagation. This makes up the basis for every page on the site (when you view the homepage for example that is no less than 4 pages being generated with php)

The edits I need to make are around the side navagation. Which I want to be like the smoothmenu example.

What I've managed so far is to get the div, ul and li tags to kind of work around the first section of this navagation - but for example, Tables by Price should have the extention when you hover over it but it is not working.

Thats the problem I am now having, and I am getting errors in Internet Explorer (where there is also an issue with size)

jscheuer1
01-13-2010, 05:30 PM
The individual include pages don't necessarily have to work by themselves, just the page that is created from them. The paths however, as represented on the page that is created from the includes, must be correct for the created page. To avoid confusion, absolute paths may be used in the HTML code of the includes.

We can look at the includes (if we have direct links to them), but it is the created page that must be made to work. In this case (as regards the Smooth Navigational Menu) that would mean that the created page's markup and scripts must conform to the instructions as given on the demo page for that menu script.

Aravona
01-14-2010, 09:17 AM
As far as I can tell they are.

The <head> section of the code is where my <head> section is generated (index page) and the <body> section is within the <body> section of the page what will be loading it (my menu.php)

The file paths are all pointing to the new folder with the .js files in it.

heres the index.php the <head> section:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?=$title?></title>
<META NAME="description" CONTENT="<?=$description?>" />
<meta name="keywords" content="<?=$keywords?>" />
<base href="http://www.leisure-shop-online.com/test/" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" id="st1" />
<link rel="stylesheet" type="text/css" href="NEW js/js/ddsmoothmenu.css" />
<link rel="stylesheet" type="text/css" href="NEW js/js/ddsmoothmenu-v.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript" src="NEW js/js/ddsmoothmenu.js">
</script>
<script type="text/javascript">

ddsmoothmenu.init({
mainmenuid: "smoothmenu1", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

ddsmoothmenu.init({
mainmenuid: "smoothmenu2", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>
</head>

<body>

the menu.php (the first section I'm trying to get working:


<div id="smoothmenu2" class="ddsmoothmenu-v">
<ul>

<?php
$query="SELECT * FROM ver_parent WHERE mID='1' AND active=1 ORDER BY pID ASC";
$result=$class->ResultSet($query);
$i=0;
$x=0;
while($row=$class->FetchObject($result)){
$hee=$_REQUEST['CID'];
//if(isset($hee)){
$query2="SELECT * FROM ver_child WHERE mID='1' AND pID='".$row->pID."' AND active=1 ORDER BY cID ASC";
$result2=$class->ResultSet($query2);
$TROwS=$class->numRows($result2);
if($TROwS==0){
?>
<li><a title="<?=$row->name?>" href="index.php?cmd=18&CID=<?=$row->pID?>" class="<?=($_REQUEST['CID']==$row->pID)?'select_left':''?>"><?=$row->name?></a></li>
<?php
}else{
?>


<li><a title="<?=$row->name?>" href="index.php?cmd=18&CID=<?=$row->pID?>" class="<?=($_REQUEST['CID']==$row->pID)?'select_left':''?>"><?=$row->name?></a>

<ul>
<?php
} $i=0;
$x=0;
while($row2=$class->FetchObject($result2)){
if($row->pID==$row2->pID){
?>
<li>
<a title="<?=$row2->name?>" href="index.php?cmd=18&CID=<?=$row2->pID?>&SCID=<?=$row2->cID?>" class="<?=($_REQUEST['SCID']==$row2->cID)?'select_left':''?>"><?=$row2->name?></a></li>


<?php
}
}
if($TROwS!=0){
?></ul></li>

<?php }
}?></li>

</ul>

<br style="clear: left" />
</div>

jscheuer1
01-14-2010, 10:09 AM
Well, unless you have a new test page, it still has (from it's served source code):


</div>
</div>
</div>



</div>

<script type="text/javascript" src="js/xpmenuv21.js"></script>
</td></tr>
</table><br />
<!--LEFT MENU END-->
</td>

The ddsmoothmenu.js is now available to the page, an improvement from last time. But is giving an error:


Error: $mainmenu.parent().get(0) is undefined
Source File: http://www.leisure-shop-online.com/test/NEW%20js/js/ddsmoothmenu.js
Line: 49

First thing though, get rid of that xpmenuv21.js tag.

The error quoted above is probably caused by this bit of code (highlighted) on the page:


<script type="text/javascript">

ddsmoothmenu.init({
mainmenuid: "smoothmenu1", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

ddsmoothmenu.init({
mainmenuid: "smoothmenu2", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>


You have no menu with that id (smoothmenu1), so either make one, or get rid of the highlighted code.

Aravona
01-14-2010, 10:17 AM
Oh dear, I feel a bit silly now. Got rid of both those bits of code.

That fixed the IE error too :) . But the side menu is now popping out on both IE and FireFox (Though annoying under my flash image)

jscheuer1
01-14-2010, 10:28 AM
This is required to get the menu over the Flash:


Add the following parameter to the OBJECT tag:


<param name="wmode" value="transparent">

Add the following attribute to the EMBED tag:


wmode="transparent"

But there may also be other issues with that, probably not though.

Aravona
01-14-2010, 11:09 AM
Thanks for your help with this :) its working now.

Now I can get the colours right. I hope the other 3 nav bars work now! I'm sure you'll hear form me if not. Thanks very much :)

Aravona
01-14-2010, 01:48 PM
I am now having problems getting my other 3 nav bars to have the hover out bit - but I cant see how I've got the tags in differently.

jscheuer1
01-14-2010, 03:27 PM
You may have already fixed this, but I see 4 items under pool tables that each have one level deep sub menus off of them that appear to be working properly. What are you still having trouble with? Like when I hover over what, what's supposed to happen that doesn't?

Aravona
01-14-2010, 03:31 PM
That one is working great.

The next section down, 'cues' is meant to have 4 sub menus, 'Accessories' is meant to have 5 sub menus.

And the bottom one isnt meant to have any. Its these middle two that aren't working now. But I've put the code in exactly the same.

jscheuer1
01-14-2010, 04:43 PM
You can only have one element per page with a given id. In CSS style this is often overlooked by browsers. But with scripts, usually the browser either gives an error, or simply takes the first one it finds and stops looking. Apparently the latter in this case as regards "smoothmenu2" here. There probably is a way to make this all one large Smooth Menu, but given your current markup, I see no easy way to do that. So, let's have three. Replace this:


ddsmoothmenu.init({
mainmenuid: "smoothmenu2", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

with:


ddsmoothmenu.init({
mainmenuid: "smoothmenu1", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
ddsmoothmenu.init({
mainmenuid: "smoothmenu2", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
ddsmoothmenu.init({
mainmenuid: "smoothmenu3", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

Notice we now have smoothmenu1, smoothmenu2, and smoothmenu3. So all that's left is to adjust these in the markup:


<div id="smoothmenu2" class="ddsmoothmenu-v">

You currently have four of those. Make the first one:


<div id="smoothmenu1" class="ddsmoothmenu-v">

Leave the second one alone. Make the third one:


<div id="smoothmenu3" class="ddsmoothmenu-v">

and the fourth one (since it has no 'flyouts') simply:


<div class="ddsmoothmenu-v">

Aravona
01-14-2010, 04:53 PM
Thank this works! :) I didnt realise I couldn't utlise the same thing more than once (I'm so used to using functions multiple times)

The site looks great now, thanks very much! You've been amazingly patient and very helpful!!