brentg
Legacy Member
Hallo iedereen
Ik ben bezig met mijn website (heb ze al eens hier gezet)
In firefox en chrome werkt hij perfect, maar als ik hem in internet explorer open werkt het menu niet, dit menu is gedaan met javascript. link naar de website: BrentG
JS code:
Html code van het menu:
Ik ben bezig met mijn website (heb ze al eens hier gezet)
In firefox en chrome werkt hij perfect, maar als ik hem in internet explorer open werkt het menu niet, dit menu is gedaan met javascript. link naar de website: BrentG
JS code:
Code:
//console
//DOM
var eMenu = document.getElementById("menu");
var eMainMenu = document.getElementById("mainMenu");
var eSubMenu = document.getElementById("subMenu");
var eMainItems = eMainMenu.getElementsByTagName("div");
var eSubItems = eSubMenu.getElementsByTagName("div");
//MouseOvers
eMainItems[0].onclick = function()
{
mHomeClick();
}
eMainItems[0].onmouseover = function()
{
mHome();
}
eMainItems[1].onmouseover = function()
{
mPers();
}
eMainItems[2].onmouseover = function()
{
mPro();
}
eMainItems[3].onmouseover = function()
{
mRecepten();
}
eMainItems[4].onmouseover = function()
{
mLinks();
}
eMainItems[4].onclick = function()
{
mLinksClick();
}
//menu related functions
function createSubMenuItem(text, script){
//creating the elements
var element = document.createElement("div");
var eTitle = document.createTextNode(text);
//modifying
element.setAttribute("class","menuSubItem");
//script included?
if (script)
{
//element.setAttribute("onclick","location.href = '"+link+"'"); obsolete
element.setAttribute("onclick",script);
console.info("Button " + text + " does: " + script);
} else {
console.info("Button " + text + " has no script");
}
element.appendChild(eTitle);
eSubMenu.appendChild(element);
}
function createSubMenuButton(imagePath, script, alt)
{
//creating elements
var blockElement = document.createElement("div");
var imageElement = document.createElement("img");
//modifying
blockElement.setAttribute("class","menuSubItem");
imageElement.setAttribute("class","imageButton");
imageElement.setAttribute("src",imagePath);
//script?
if (script) imageElement.setAttribute("onclick",script);
if (alt) imageElement.setAttribute("onclick",alt);
blockElement.appendChild(imageElement);
eSubMenu.appendChild(blockElement);
}
function clean(node)
{
var len = node.childNodes.length;
while (node.hasChildNodes())
{
node.removeChild(node.firstChild);
}
}
//other functions
function setCookie(name, value, expirationdays){
var expirationDate = new Date();
expirationDate.setDate(expirationDate.getDate() + expirationdays);
var cookieValue = value + "; expires="+expirationDate.toUTCString();
document.cookie= name+" = "+cookieValue;
}
//menus
function mHomeClick()
{
window.location.href="index.html";
}
function mHome()
{
clean(eSubMenu);
createSubMenuItem("comment","location.href = 'nl/comment.html'");
createSubMenuItem("contact","location.href = 'nl/contact.html'");
}
function mPers()
{
clean(eSubMenu);
createSubMenuItem("bio","location.href = 'nl/biografie.html'");
createSubMenuItem("hobby's","location.href = 'nl/hobby.html'");
createSubMenuItem("sociaal","location.href = 'nl/sociaal.html'");
}
function mPro()
{
clean(eSubMenu);
createSubMenuItem("curriculum","location.href = 'nl/curriculum.html'");
createSubMenuItem("online", "location.href = 'nl/online.html'");
createSubMenuItem("coding","location.href = 'nl/coding.html'");
createSubMenuItem("grafisch","location.href = 'nl/grafisch.html'");
}
function mStandard()
{
}
function mRecepten()
{
clean(eSubMenu);
createSubMenuItem("koude gerechten","location.href = 'nl/koude_gerechten.html'");
createSubMenuItem("warme gerechten","location.href = 'nl/warme_gerechten.html'");
createSubMenuItem("desserts","location.href = 'nl/desserts.html'");
}
function mLinksClick()
{
window.location.href="nl/links.html";
}
function mLinks()
{
clean(eSubMenu);
}
//Subfunctions
function switchColor(sheet){
setCookie("sheet",sheet,100);
window.location.reload();
}
Html code van het menu:
HTML:
<nav>
<div class="mainMenu" id="mainMenu">
<div class="menuItem">home</div>
<div class="menuItem">persoonlijk</div>
<div class="menuItem">portfolio</div>
<div class="menuItem">recepten</div>
<div class="menuItem">links</div>
</div>
<div class="subMenu" id="subMenu"> </div>
</nav>
)