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
https://forums.phpfreaks.com/topic/195021-javascript-expanding-menu-problem/
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

I guess I wasn't clear enough.  It works for me.

 

Try this in the near future and you will presumably see what i get:

 

http://www.yourwebskills.com/fred.html

 

That is a scratchpad page so next time I need to try something it will not show your page.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.