My web site has a common horizontal menu and I’d like to put this into a single html file so I only need to change it in one place.
My solution is to put the menu into an iframe and have a DIV id=menu in the main page. In the menuFrame html I have an onload with this:
<script language="JavaScript">
function doLoad() {
window.parent.document.getElementById("menu").innerHTML = document.body.innerHTML;
}
</script>
This works fine in IE, Safary, Mozilla but not in Chrome.
Any ideas?
For various reasons relating to usability and browser support; the better choice is pretty much always to not use an iframe for this; but rather include the menu in the text of the page using a server-side language like PHP or similar.
If, as occasionally happens, your host doesn’t support PHP, it’s time to switch hosting services.
As for the code itself, it’s pretty simple: