PDA

View Full Version : Mega Menu in external file



lio
08-04-2011, 09:48 AM
1) Script Title: DD Mega Menu

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex1/ddmegamenu.htm

3) Describe problem:
Can this menu alsp be modified to put the menu contents in an external file like with Smooth Menu ?

:)

molendijk
08-04-2011, 01:35 PM
1.
Follow the steps given at http://www.dynamicdrive.com/dynamicindex1/ddmegamenu.htm for constructing a standalone menu. Let's call the file: menu.html.

2.
In menu.html, replace:

<script>
ddmegamenu.docinit({
menuid:'solidmenu',
dur:200 //<--no comma after last setting
})

ddmegamenu.docinit({
menuid:'megaanchorlink',
dur:500,
easing:'easeInOutCirc' //<--no comma after last setting
})
</script>
with:

<script type="text/javascript" src="init.js"></script>
and create a file init.js containing the following lines:

ddmegamenu.docinit({
menuid:'solidmenu',
dur:200 //<--no comma after last setting
})


ddmegamenu.docinit({
menuid:'megaanchorlink',
dur:500,
easing:'easeInOutCirc' //<--no comma after last setting
})
3.
Also create a file include_menu.js and put the following lines in it:

function HttpRequest(url){
var pageRequest = false //variable to hold ajax object
/*@cc_on
@if (@_jscript_version >= 5)
try {
pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try {
pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e2){
pageRequest = false
}
}
@end

@*/ if (!pageRequest && typeof XMLHttpRequest != 'undefined')
pageRequest = new XMLHttpRequest()

if (pageRequest){ //if pageRequest is not false
pageRequest.open('GET', url, false) //get page synchronously
pageRequest.send(null)
document.write(pageRequest.responseText)

}
}

4.
Now in each file into which you want to insert the menu, put:

head:
<script type="text/javascript" src="include_menu.js"></script>

body (somewhere):
<script type="text/javascript">HttpRequest('menu.html')</script>
The files into which you insert the menu should have a valid doctype, for instance:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

Note that the arrows in the menu don't show if you are using IE. That's also the case at http://www.dynamicdrive.com/dynamicindex1/ddmegamenu.htm
===
Arie Molendijk.

molendijk
08-04-2011, 05:25 PM
THIS (http://www.dynamicdrive.com/forums/blog.php?b=244) works too (apply it to your menu).
===
Arie.

lio
08-04-2011, 05:47 PM
Many thanks, it works :)
I have now a look to your second reply...