How Can I Embed An Existing Multi-level Drop Down Menu Without Inserting The Whole Code?
Solution 1:
Well here is a bit of a long winded javascript approach that might keep your IT guys happy:
window.onload = newFunction("load('embed-me.html','content')"); // Replace with URL of your file and ID of div you want to load into.functionahah(url, target) {
document.getElementById(target).innerHTML = ' Fetching data...';
if (window.XMLHttpRequest) {
req = newXMLHttpRequest();
} elseif (window.ActiveXObject) {
req = newActiveXObject("Microsoft.XMLHTTP");
}
if (req != undefined) {
req.onreadystatechange = function() {ahahDone(url, target);};
req.open("GET", url, true);
req.send("");
}
}
functionahahDone(url, target) {
if (req.readyState == 4) { // only if req is "loaded"if (req.status == 200) { // only if "OK"document.getElementById(target).innerHTML = req.responseText;
} else {
document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
}
}
}
functionload(name, div) {
ahah(name,div);
returnfalse;
}
Not written by me(LINK) (I just added the run on page load bit).
Tested and working (in Chrome at least). Though your site will have no menu if the user has javascript disabled!
EDIT:
Example...
<body><scripttype="text/javascript"src="embed-me.js"></script><!-- load the javascript --><divid="content"></div><!-- html will be embedded here --></body>
Solution 2:
I use the following php code and works very nice. It doesn't even show when you check the source code online.
<?phpinclude("menu.php"); ?>
Solution 3:
Use php Include !!
Okay first.. copy the menu code and save it on to a file called menu-1.php
then whenever you want to use your menu; just type the following code:
<?phpinclude("menu-1.php"); ?>
This is a good way to do menu's because every time you need to update your menu, you wont have to update every single page, just update your menu-1.php
P.S. PHP might not show up on your local machine unless you are using wamp or xamp
Post a Comment for "How Can I Embed An Existing Multi-level Drop Down Menu Without Inserting The Whole Code?"