Jump to content

Javascript Expanding Menu Problem


gazfocus

Recommended Posts

I am trying to make a Javascript expand menu which works locally but not once I upload it to the server. Can anyone help?

 

The html is:

    <a alt="Digital Print Options - Click to expand" href="javascript:void(0);" onclick="expandit('expand1');">Digital Print Options</a><div id="expand1" style="display:none">
  <a alt="Childrens Options" href="Digital-Print-Childrens.php">Children's Options</a>
<br />  <a alt="Adult Options" href="Digital-Print-Adult.php">Adult Options</a><br /></div>

 

The Javascript is:

// Navigation Expander

function expandit(curobj, hide) {
if(document.getElementById(curobj)) {
  		folder=document.getElementById(curobj).style;
} else {
	if(ns6==1||operaaa==true) {
		folder=curobj.nextSibling.nextSibling.style;
	} else {
		folder=document.all[curobj.sourceIndex+1].style;
	}
   }
if(folder.display=="none")
{
	folder.display="";
} else {
	folder.display="none";
}
if(hide) {
	var hide_objects = hide.split(",");
	for(i=0; i<hide_objects.length; i++) {
		hide_objects[i]=hide_objects[i].replace(/^\s*(.*)/, "$1");
		hide_objects[i]=hide_objects[i].replace(/(.*?)\s*$/, "$1");
		if(document.getElementById(hide_objects[i])) {
			hidden=document.getElementById(hide_objects[i]).style;
			if(hidden.display=="") {
				hidden.display="none";
			}
		}
	}
}
}

Link to comment
Share on other sites

Works for me with IE8 and Firefox 3.6.

 

I'd suggest using a CSS-only menu though as that is going to work acorss more users' systems.

As I said, it works locally but when I upload the pages to the server, it ceases to work. Can anyone point me in the right direction for a css version then? Ta

Link to comment
Share on other sites

What error do you get?

When I click on the parent item, it just does nothing.

 

I said what error do you get? In FF you can find JS errors in the error console (tools > error console). Most of the popular browsers I believe have some form of console for you to check errors.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.