Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code for OS X 1

Status
Not open for further replies.

HardHat

IS-IT--Management
Aug 7, 2003
14
US
HI,

I have a collapse/expand side menu that has been operating fine for a couple of years. The company has just started rolling out OS X on the macs - the menu system does not work correctly on this new system. Instead of collapsing/expanding the menu just reproduces itself within the main frame. The links within the menu work fine, but the menu that is reproduced within the main frame does not expand/collapse.

The code is below - can anyone see where I have gone wrong ?



<SCRIPT LANGUAGE="JavaScript">

function BrowserVerChecker() {
var BrowserName = navigator.appName;
if (BrowserName=="Netscape") this.BrowserName = "NS";
else
if (BrowserName=="Microsoft Internet Explorer") this.BrowserName = "IE";
else
this.BrowserName = BrowserName;
this.BrowserVersion = navigator.appVersion;
this.Version = parseInt(this.BrowserVersion);
this.NS4 = (this.BrowserName=="NS" && this.Version==4);
this.NS5 = (this.BrowserName=="NS" && this.Version==5);
this.NS6 = (this.BrowserName=="NS" && this.Version==6);
this.IE = (this.BrowserName=="IE" && this.Version>=5);
}
Check = new BrowserVerChecker();

var nom = 6; // Number of menus

var ttls = new Array(); // An array for the title objects
var subs = new Array(); // An array for the submenu objects
var lastn;
var lastmove;

if (document.layers){
visible = 'show';
hidden = 'hide';
}else{
visible = 'visible';
hidden = 'hidden';
}

for (var i = 1; i <= nom; i++){
ttls = ('title' + i);
subs = ('submenu' +i);
}


lastn = (nom + 1);
lastmove = 0;

function lasttoggle(n,move){
if (n <= nom){
menu = ('submenu' + n);
if (Check.NS4){
submenu = document.layers[menu];
}else if (Check.IE){
submenu = document.all(menu).style;
}else{
submenu = document.getElementById(menu);
submenu = submenu.style
}
if (submenu.visibility == visible){
submenu.visibility = hidden;
for (var i = (n+1); i <= nom; i++){
if (Check.NS4){
document.layers[ttls].top -= move;
document.layers[subs].top -= move;
}else if (Check.IE){
document.all(ttls).style.pixelTop -= move;
document.all(subs).style.pixelTop -= move;
}else{
document.all(ttls).style.pixelTop -= move;
document.all(subs).style.pixelTop -= move;}
}
}
}
}

function toggle(n,move){
menu = ('submenu' + n);
if (Check.NS4){
submenu = document.layers[menu];
}else if (Check.IE){
submenu = document.all(menu).style;
}else{
submenu = document.getElementById(menu);
submenu = submenu.style
}
if (submenu.visibility == visible){
submenu.visibility = hidden;
for (var i = (n+1); i <= nom; i++){
if (Check.NS4){
document.layers[ttls].top -= move;
document.layers[subs].top -= move;
}
else if (Check.IE){
document.all(ttls).style.pixelTop -= move;
document.all(subs).style.pixelTop -= move;
}else{
document.all(ttls).style.pixelTop -= move;
document.all(subs).style.pixelTop -= move;}
}
}
else{
submenu.visibility = visible;
if (lastn != n){
lasttoggle(lastn,lastmove);
}
for (var i = (n+1); i <= nom; i++){
if (Check.NS4){
document.layers[ttls].top += move;
document.layers[subs].top += move;
}else if (Check.IE){
document.all(ttls).style.pixelTop += move;
document.all(subs).style.pixelTop += move;
}else{
document.all(ttls).style.pixelTop += move;
document.all(subs).style.pixelTop += move;}
}
}
lastn = n;
lastmove = move;
ChangeImage();
}


function ChangeImage(){
for(var i =1; i <= nom; i++){
var menu = 'submenu' + i;
var submenu;
var image;
var title = 'title' + i;
var picNo = 'pic' + i;

if(Check.NS4){
submenu = document.layers[menu];
image = document.layers[title].document[picNo];
}else if (Check.IE){
submenu = document.all(menu).style;
image = document.all(picNo);
}else{
submenu = document.all(menu).style;
image = document.all(picNo);
}

switch(i){
case 1:
Pic2 = 'Images/buttons/LinksTime2.gif';
Pic1 = 'Images/buttons/LinksTime.gif';
break;
case 2:
Pic2 = 'Images/buttons/LinksFortune2.gif';
Pic1 = 'Images/buttons/LinksFortune.gif';
break;
case 3:
Pic2 = 'Images/buttons/LinksPeople2.gif';
Pic1 = 'Images/buttons/LinksPeople.gif';
break;
case 4:
Pic2 = 'Images/buttons/LinksWallpaper2.gif';
Pic1 = 'Images/buttons/LinksWallpaper.gif';
break;
case 5:
Pic2 = 'Images/buttons/LinksIntranetLinks2.gif';
Pic1 = 'Images/buttons/LinksIntranetLinks.gif';
break;
case 6:
Pic2 = 'Images/buttons/LinksWebLinks2.gif';
Pic1 = 'Images/buttons/LinksWebLinks.gif';
break;
}
if (submenu.visibility == visible){
image.src = Pic1
}else{
image.src = Pic2
}
}
}


function TimeLinks(form)
{
var strURL = form.selTimeLinks.options[form.selTimeLinks.selectedIndex].value;
window.open(strURL, "Main");
}

function TWLinks(form)
{
var strURL = form.selTWLinks.options[form.selTWLinks.selectedIndex].value;
window.open(strURL, "Main")
}

// End -->
</SCRIPT>

<BASE TARGET="Main">
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
</HEAD>
<BODY text=#000000 vLink=#c0c0c0 link=#c0c0c0 bgColor=#ffffff leftMargin=0
topMargin=0><SPAN class=Date>
<SCRIPT language=JavaScript>
<!-- Begin
var months=new Array(12);
months[0]="January";
months[1]="February";
months[2]="March";
months[3]="April";
months[4]="May";
months[5]="June";
months[6]="July";
months[7]="August";
months[8]="September";
months[9]="October";
months[10]="November";
months[11]="December";

var time=new Date();
var strMonth=months[time.getMonth()];
var strDay=time.getDate();
var strYear=time.getYear();

if (strYear < 2000)
strYear = strYear + 1900;

var strToday = strMonth + " " + strDay + ", " + strYear

//document.write (strToday);
// End -->

 

It might have something to do with the fact that the code references "document.all" outside of the "IE" checks. Given that "document.all" is IE only, this behaviour is hard to explain.

Personally, unless you really need to support older browsers (IE 4 / NN 4), I would scrap all of the browser checks, and stick to using "document.getElementById" for everything.

Hope this helps,
Dan
 
Hi,

I've made the change you suggested, now something different happens. On any version of mac OS (9.2 or OS X) the side menu works after a fashion - it collapse/expands fine but also puts a copy into the main (center) fram. The page is made up of 3 frames - sideframe, topfram (both are menu's) and then the main frame homepage.
 
Hi,

I checked the code again and I noticed a small mistake - this has been altered and now the system works perfectly.

Thanks for your help !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top