Click to See Complete Forum and Search --> : Pull down menu
CreativeMind
03-15-2007, 09:52 AM
Hello, I have a question regarding browser issue. I have created a pull down menu and it looks great in IE6 but not good in Firefox browser. I have attached a sample image to look at and CSS. You will notice that the Firefox browser will not display the blue background. Thanks!
I would need to see your entire code, -mostly to see how the <ul> is structured, but right off, it appears and IE is incorrectly expanding the width of the <li> to encompass the anchor, whereas Firefox is probably doing exactly what it was told to do. -The fault is most probably IE doing it wrongly (and looking good whilst doing it).
It's probably not a difficult thing to remedy once the entire code is shown. :)
CreativeMind
03-16-2007, 10:52 AM
Thanks WebJoel for helping. I was not able to paste in the entire code because it was too much texts. I was also not able to atached word doc because it's a large size file. Is there another way to send the entire code to you?
Thanks!
CreativeMind
03-16-2007, 03:20 PM
Thanks WebJoel for helping. Below are javascript for the menu:
var menuWidth = 160;
//function menuInit() {
var topMenu = [];
var unitNum;
for (unitNum = 0; unitNum < menuTree.length && menuTree[unitNum].label != unitName; unitNum++);
if (unitNum == menuTree.length)
topMenu.add(topMenuItem('Unit', 0, menu(menuTree)));
else {
topMenu.add(topMenuItem(unitName, 0, menu(menuTree)));
topMenu.add(topMenuItem(chapterName, menuWidth, menu(menuTree, unitNum)));
if (lessonName) {
var chapterNum;
for (chapterNum = 0; chapterNum < menuTree[unitNum].menu.length && menuTree[unitNum].menu[chapterNum].label != chapterName; chapterNum++);
topMenu.add(topMenuItem(lessonName, menuWidth * 2, menu(menuTree, unitNum, chapterNum)));
}
}
addContent(_('breadcrumb'), topMenu);
//}
function menu(menuTree, submenu) {
if (submenu != undefined && typeof(submenu) == 'number') {
for (var i = 1; i < arguments.length; i++) {
menuTree = menuTree[arguments[i]].menu;
if (!menuTree)
return false;
}
submenu = false;
}
var menuElement = element('div', { className : 'menu hidden' });
for (var i = 0; i < menuTree.length; i++) {
var item = menuItem(menuTree[i]);
if (i == 0)
item.firstChild.style.borderTop = 'none';
if (i == menuTree.length - 1)
item.firstChild.style.borderBottom = 'none';
addContent(menuElement, item);
}
function addContent(element, content) {
if (!content)
return;
var type = typeof(content);
if (type == 'function')
return;
else if (content instanceof Array)
for (var i = 0; i < content.length; i++)
addContent(element, content[i]);
else if (type != 'object')
element.appendChild(document.createTextNode(content));
else if (content.nodeName)
element.appendChild(content);
else
copyProperties(element, content);
}
function clearContent(element) {
while (element.hasChildNodes())
element.removeChild(element.lastChild);
}
function setContent(element, content) {
clearContent(element);
addContent(element, content);
}
/**************************************************************************
* element(name, { attributes | children })
* creates element with name, attributes and children specified
*
**************************************************************************/
function element(name) {
var e = document.createElement(name);
for (var i = 1; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg)
continue;
addContent(e, arguments[i]);
}
addContent(e, elementMethods);
return e;
}
function copyProperties(to, from) {
for (var p in from) {
if (!to[p] || typeof(to[p]) != 'object' || typeof(from[p]) != 'object') {
to[p] = from[p];
} else {
copyProperties(to[p], from[p]);
}
}
}
/**************************************************************************
* Element class methods: add and remove class names from element class attribute
*
**************************************************************************/
var elementMethods = {
addClass : function(style) {
if (!this.className || this.className.length == 0)
this.className == style;
else if (!this.className.split(/\s+/).contains(style))
this.className += ' ' + style;
},
/**************************************************************************
* positioned(x, y, z, widget)
* absolutely positions widget at x, y, z
*
**************************************************************************/
function positioned(x, y, widget) {
return element('div',
{ style : { position : 'absolute', 'left' : x + 'px', top : y + 'px' }},
widget);
}
/**************************************************************************
* multiStateImage({ srcPath })
* an img tag which can change state using img.show(n) method
*
**************************************************************************/
function multiStateImage() {
var attrs = { states : [],
setState : function(n) { this.src = this.states[n]; }
};
Let me know if you need more code. I am not able to paste the entire code because it is much code. I will have to paste little at a time.
WebJoel
03-17-2007, 10:56 AM
That's enough code. :o Javascript is not my strongest suit, -I was rather hoping to see an HTML/CSS thing (which you also included). As for 'size of file exceeding WD attachment size', you should get a ZIP-program, ZIP/compress your files as an attachment.
Anyway, that it works for IE6 and poorly for Firefox suggest to me that the CSS or HTML needs work (for, if the javascript works at all, it probably is 100% all-browser being client-side you know).
I will examine the CSS, but would probably need to view the actual HTML (the "<ul><li><a href="etc etc">Link</a></li>....</ul>"> portion. Otherwise, I could only guess at how it is written. ;)
CreativeMind
03-17-2007, 11:47 AM
WebJoel, please see my zip file as an attachment. Thanks and let me know if you are not able to open it. I copied the code and paste within word doc. You can also open with notepad as well.
WebJoel
03-17-2007, 06:37 PM
Wow... I don't even know where to begin looking. All that javascript... :mad: -Not my favorite thing.
Are all these external files required? I haven't made any of them 'absolute path' so haven't seen what they do 'on my offline editor', -but sheez.... that's going to be a few http-requests going on there, eh? :p
Looking again at that image you posted, it almost looks like my first assessment of IE incorrectly-expanding to encompass the elements of text. In the Firefox view, the small variance of width between "Unit B" and "Unit C" might be attributable to the kern difference between the "B" and "C", and Firefox's (presumeably correct behaviour) of wrapping it tightly reveals a minor variation in width...
I think I am not qualified to help with this one :o . Is this 'online' somewhere? If I could get the paths 'absolute', the thing might work on my offline-editor and maybe I can see what you describe...
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.