Click to See Complete Forum and Search --> : Change this function to support in Mozilla, anyone can help me?


shean71
06-14-2006, 03:23 AM
function BrowserIsNS() {
// var MS = navigator.appVersion.indexOf("MSIE");
// var isIE4 = ((parseInt(navigator.appVersion.substring(MS+5,MS+6)) >= 4) &&
// (navigator.appVersion.indexOf("MSIE"))>0);

var NSVER = parseInt(navigator.appVersion.substring(0,1));
if ((navigator.appName == "Netscape") && (NSVER == 4)) {
ISNS4 = true;
} else {
ISNS4 = false;
}
// alert(window.ISNS4);
return window.ISNS4;
}
// if (window.isNS4) {
// genMenuNS(title,image);
// } else {
// genMenuIE(title,image);
// }
//}

function genMenuIE(title,image) {
var htmlStr = new String;
htmlStr = "";
var aWidth = screen.availWidth;
if (aWidth >= 640) { col = 3;} else { col = 2;}
itemHeight = 150;
itemWidth = 200;
menuBorder= 10;
topOffset = 50;
leftOffset = (aWidth - ((itemWidth + menuBorder) * col - menuBorder))/2;
// menuLength = menu.length;
maxRow = menuLength / col ;
// document.open();
// var htmlStr = "<HTML><HEAD>" +
// "<link rel='stylesheet' HREF=/styles/general.css>" +
// "</HEAD><BODY>\n";
for (var i=0;i<maxRow;i++) {
for (var j=0;j<col;j++) {
itemTop = i * ( itemHeight + menuBorder ) + topOffset;
itemLeft = j * ( itemWidth + menuBorder ) + leftOffset;
document.write("<div id='itemcnt' style='position:absolute;top:" +
itemTop + ";left:" + itemLeft + ";height:" +
itemHeight + ";width:" + itemWidth + "'>\n" +
"<img src='" + image + "'>\n" +
"</div>\n");
}
}
// htmlStr += "</BODY></HEAD></HTML>\n";
// alert(htmlStr);
// document.write(htmlStr);
// document.close();
}

function genMenuNS(title,image) {
var htmlStr = new String;
htmlStr = "";
var aWidth = screen.availWidth;
if (aWidth >= 640) { col = 3;} else { col = 2;}
itemHeight = 150;
itemWidth = 200;
menuBorder= 10;
topOffset = 50;
leftOffset = (aWidth - ((itemWidth + menuBorder) * col - menuBorder))/2;
// menuLength = menu.length;
maxRow = menuLength / col ;
// document.open();
// var htmlStr = "<HTML><HEAD>" +
// "<link rel='stylesheet' HREF=/styles/general.css>" +
// "</HEAD><BODY>\n";
for (var i=0;i<maxRow;i++) {
for (var j=0;j<col;j++) {
itemTop = i * ( itemHeight + menuBorder ) + topOffset;
itemLeft = j * ( itemWidth + menuBorder ) + leftOffset;
document.write("<div style='position:absolute;top:" +
itemTop + ";left:" + itemLeft + ";height:" +
itemHeight + ";width:" + itemWidth + "'>\n" +
"<img src='" + image + "'>\n" +
"</div>\n");
}
}
// htmlStr += "</BODY></HEAD></HTML>\n";
// alert(htmlStr);
// document.write(htmlStr);
// document.close();
}

function arrangeNS(menuLength) {
var itemOffset;
var myLayer;
var aWidth = screen.availWidth;
if (aWidth >= 640) { col = 3;} else { col = 2;}
itemHeight = 150;
itemWidth = 200;
menuBorder= 10;
topOffset = 50;
leftOffset = (aWidth - ((itemWidth + menuBorder) * col - menuBorder))/2;
maxRow = menuLength / col ;
for (var i=0;i<maxRow;i++) {
for (var j=0;j<col;j++) {
// eval("myLayer=document.layers[\"img_" + (i * col + j) + "\"]");
// myLayer.moveTo( j * ( itemWidth + menuBorder ) + leftOffset,i * ( itemHeight + menuBorder ) + topOffset);

eval("myLayer=document.layers[\"item_" + (i * col + j) + "\"]");
myLayer.moveTo(j * ( itemWidth + menuBorder ) + leftOffset,i * ( itemHeight + menuBorder ) + topOffset);


}
}
//document.layers["img_4"].top = 1 * (itemHeight + menuBorder ) + topOffset;
//document.layers["img_4"].left = 1 * (itemHeight + menuBorder ) + topOffset;
}
function arrangeIE() {

}

phpnovice
06-14-2006, 11:54 AM
If you take the time to identify the specific lines that don't work, then I'm sure someone would be willing to take the time to help you.

felgall
06-14-2006, 03:24 PM
Just about all of that code is designed for Netscape 4 and IE4 and only works in more recent IE versions because of backwards compatibility. There isn't enough of the script that is designed to work with version 5+ browsers to suggest keeping ANY of that code. I would start over with a modern script in place of that antique as that will be much faster. A quick search of the top Javascript sites should soon find you a suitable replacement.