PDA

View Full Version : IE7 hack for javascript menu



deathbycheese
04-26-2012, 11:31 PM
The main menu tabs on this website don't show up in IE7. Can someone help me find a hack for this?

http://www.heritagechurch.us/Sandbox

Thanks,
dbc

jscheuer1
04-27-2012, 04:36 AM
Only for future reference:

Please post about Dynamic Drive Scripts in the Dynamic Drive Scripts Help section here where I've moved this thread, and:

Warning: Please include a link to the DD script(s) in question in your post. See this post (http://www.dynamicdrive.com/forums/showpost.php?p=7) for more information.

For current reference:

Your page is in violation of Dynamic Drive's usage terms (http://www.dynamicdrive.com/notice.htm), which, among other things, state that the script credit must appear in the source code of the page(s) using the script. Please reinstate the notice first.

That all said, works fine on the demo page:

http://www.dynamicdrive.com/dynamicindex1/tabmenu.htm

On the page you linked to it's something about the markup (possibly menu header tabs without subItem content) and IE 7 that has IE 7 at times calculating a negative value for leftPos here:


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';

such that when you get to the highlighted line, IE 7 throws an error. Replace that line with:


subItem.style.paddingLeft = Math.max(0, leftPos) + 'px';

And it will be fine.

deathbycheese
04-27-2012, 04:45 PM
Thanks John, for pointing out the missing DD reference. I know it was on there in my earlier versions, but am not surprised it fell off sometime during the mad melee that has been this project. :confused: I will be sure to always double-check from now on.

Also, I will try your suggestions and let you know if this resolves the issue.

Thanks again,
dbc

edit:
Wait, it DOES have the DD reference. You're probably looking at the includes only and not the actual .js file. If you know a way for the reference to be 'included' when using PHP includes, I'd be happy to adjust it accordingly.

I knew I was a loyal DD supporter. :D

deathbycheese
04-27-2012, 05:02 PM
John, you're a god.

dbc

jscheuer1
04-27-2012, 08:33 PM
Wait, it DOES have the DD reference. You're probably looking at the includes only and not the actual .js file. If you know a way for the reference to be 'included' when using PHP includes, I'd be happy to adjust it accordingly.

I knew I was a loyal DD supporter. :D

Um, the credit is supposed to be in the page's source code, not in the javascript file (though it can be there too). You took an on page script and made it external with this in the page's source code:


<script type="text/javascript" src="./script/mainNavScript.js"></script>

According to the rules, that should be:


<script type="text/javascript" src="./script/mainNavScript.js">
/***********************************************
* Tab Menu- By Alf Magne Kalleland www.dhtmlgoodies.com
* Script featured and available at Dynamic Drive: http://www.dynamicdrive.com/
* This notice must stay intact for use
***********************************************/
</script>


John, you're a god.

dbc

Thanks, and you're welcome.

deathbycheese
04-28-2012, 05:09 PM
Thanks. I will fix it today.

One more issue:

I can't get the submenu to stay visible while on a corresponding page. It times out and disappears. Do you know how to fix that? My beta testers keep complaining about it.

Here's the link again for easy reference:
http://www.heritagechurch.us/Sandbox

Thanks again in advance!
dbc