Forum Moderators: open
Here is a link to the site:
<snipped link>
This is urgent as I am getting people contacting me wondering what's wrong with the site. I have confirmed that it is when they upgrade their IE and try to urge them to switch to FF, but that's not a good "fix".
I am working on a CSS version of the menu - along with a whole new site design - but I need this issue resolved as soon as possible in the interim.
Anything anyone can do to help find the problem would be greatly appreciated.
Regards,
dbc
[edited by: coopster at 8:05 pm (utc) on July 27, 2009]
[edit reason] no personal urls please TOS [webmasterworld.com] [/edit]
but I need this issue resolved as soon as possible in the interim.
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
add the above tag to the header of all your pages, and IE8 should render your pages the same as IE7. That's the interim solution, and works well for CSS too
Afraid I can't help with the JS, and your link will be removed per TOS [webmasterworld.com] anyway, however if you're already working on a change to the site perhaps the above solution will do meantime.. PS making sure your pages all have valid Doctypes going forward to IE8
I have read the TOS and my link is not for any purpose other than to get help. In fact, the organization wouldn't even be pertinent to most people on this forum.
Also, I tried running a debug and here's the function it doesn't like:
function initMenu()
{
var mainNavObj = document.getElementById('mainNav');
var mainSubNavObj = document.getElementById('mainSubNav');
mainNavObj.style.visibility=mainSubNavObj.style.visibility="visible"
var menuItems = mainNavObj.getElementsByTagName('A');
if(document.all){
mainNavObj.style.visibility = 'hidden';
document.getElementById('mainSubNav').style.visibility='hidden';
}
The debug notification for "mainnavObj..." line, on line 5 above, states "Object required".
Since I don't know JS, I don't even know where to start fixing this.
thanks again,
dbc
[edited by: coopster at 8:13 pm (utc) on July 27, 2009]
[edit reason] no urls please [/edit]
The debug notification for "mainnavObj..." line, on line 5 above, states "Object required".
This typically means that there isn't any element on the page with an ID assigned of "mainNav". Basically, somewhere in your HTML, you need to have something that has this specifically assigned:
<div id="mainNav">
...your navigation links...
</div>
Whatever is wrapped around your main navigation links should have that ID assigned.
I am also getting this:
'offsetLeft' is null or not an object
referring to the following code which occurs later in the document:
...
else{
var leftPos = mainMenuLinks[subCounter-1].offsetLeft;
document.getElementById('submenu_'+subCounter).style.paddingLeft = leftPos + 'px';
subItem.style.position ='absolute';
if(subItem.offsetWidth > parentWidth){
leftPos = leftPos - Math.max(0,subItem.offsetWidth-parentWidth);
}
subItem.style.paddingLeft = leftPos + 'px';
subItem.style.position ='static';
}
...
I would hate to have to post the whole entire JS code here, but just can't figure out how to get everyone on the same page so that you can fully see what's going on. Any ideas?
dbc
var leftPos = (mainMenuLinks[subCounter-1].offsetLeft != 'undefined') ? mainMenuLinks[subCounter-1].offsetLeft : 0;
It may actually be that the problem is with the object handle... You could add an alert to test what that handle is trying to get an .offsetLeft of:
alert(mainMenuLinks[subCounter-1]);
Do I write it like this? :
...
else{
var leftPos = mainMenuLinks[subCounter-1].offsetLeft != 'undefined') ?
mainMenuLinks[subCounter-1].offsetLeft : 0;
alert(mainMenuLinks[subCounter-1]);
document.getElementById('submenu_'+subCounter).style.paddingLeft = leftPos + 'px';
subItem.style.position ='absolute';
if(subItem.offsetWidth > parentWidth){
leftPos = leftPos - Math.max(0,subItem.offsetWidth-parentWidth);
}
subItem.style.paddingLeft = leftPos + 'px';
subItem.style.position ='static';
}
...
thanks all for your patience,
dbc
Another longer way of writing the same code is below, but it should be easier to retype and less susceptible to copy and paste errors.
if( mainMenuLinks[subCounter-1].offsetLeft != 'undefined' ){
var leftPos = mainMenuLinks[subCounter-1].offsetLeft;
} else {
var leftPos = 0;
}
The alert line will be helpful if the other code doesn't fix the problem. If it fixes the error, then you can safely delete the alert(...); line. If the error persists (or a new error crops up) then just post back with what the alert says.
Thank you for your patience. :)
However, here is what I did with the code. Maybe I placed everything incorrectly? :
...
if(leftAlignSubItems){
// No action
} else {
var leftPos = mainMenuLinks[subCounter-1].offsetLeft;
document.getElementById('submenu_'+subCounter).style.paddingLeft = leftPos + 'px';
subItem.style.position ='absolute';
if(subItem.offsetWidth > parentWidth){
leftPos = leftPos - Math.max(0,subItem.offsetWidth-parentWidth);
}
}
subItem.style.paddingLeft = leftPos + 'px';
subItem.style.position ='static';
if( mainMenuLinks[subCounter-1].offsetLeft != 'undefined' ){
var leftPos = mainMenuLinks[subCounter-1].offsetLeft;
} else {
var leftPos = 0;
}
I sure wish I knew this stuff! You outta see my mad html/css skilz. :)
} else {
var leftPos = mainMenuLinks[subCounter-1].offsetLeft;
Is where you should place that "if...else" block:
} else {
if( mainMenuLinks[subCounter-1].offsetLeft != 'undefined' ){
var leftPos = mainMenuLinks[subCounter-1].offsetLeft;
} else {
var leftPos = 0;
}
Then it should work (or at least fix that one issue). :)
...
var mainMenuLinks = mainMenuObj.getElementsByTagName('A');
var subCounter = 1;
var parentWidth = mainMenuObj.offsetWidth;
while(document.getElementById('submenu_' + subCounter)){
var subItem = document.getElementById('submenu_' + subCounter);
if(leftAlignSubItems){....
...
thanks again.
dbc
I just set the "leftAlignSubItems" variable to be true and it not only works great, but looks fine too.
Thanks SO much whoisgregg. Your diligence on this is very appreciated and has saved me lots of stress. I just hope that someday I can help someone on the forums as well as you helped me.
a loyal fan,
dbc