Bonjour,
Je suis nouveau dans ce language mais on m'a demandé de régler un problème concernant un menu contextuel avec Firefox.
En fait, lorsque l'on clic sur un élément dans la page web, un
petit menu contextuel s'affiche. A la base, il semblerait que cela a
été créé pour IE et Netscape. Le problème étant que l'on utilise de
plus en plus firefox (on se demande bien pourquoi lol) et du coup la
manip ne fonctionne plus alors que sous IE pas de problème.
voila un extrait du code où il semblerai y avoir un problème :
NS4 = (document.layers);
IE4 = (document.all);
ver4 = (NS4 || IE4);
IE5 = (IE4 && ((navigator.appVersion.indexOf("5.")!=-1) || (navigator.appVersion.indexOf("6.")!=-1)) );
function makeElement(whichEl,whichWidth,whichParent,whichContainer)
{
PrintAlert ("function makeElement");
if (NS4)
{
if (whichWidth)
{
elWidth = whichWidth;
}
else
{
elWidth = (whichContainer) ? whichContainer.menuWidth :
whichParent.menuWidth;
if (whichContainer)
elWidth = elWidth-(borWid*2)-(itemPad*2);
}
if (!whichContainer)
whichContainer = menuLoc;
eval(whichEl + "= new Layer(elWidth,whichContainer)");
}
else
{
if (IE5)
{
newDiv = menuLoc.document.createElement("DIV");
newDiv.style.position = "absolute";
newDiv.id = whichEl;
menuLoc.document.body.appendChild(newDiv);
}
else
{
elStr = "<DIV ID=" + whichEl + "
STYLE='position:absolute'></DIV>";
menuLoc.document.body.insertAdjacentHTML("BeforeEnd",elStr);
}
if (isFrames)
eval(whichEl + "= menuLoc." + whichEl);
}
return eval(whichEl);
}
La console javascript me renvoie :
Erreur : menuLoc.document.body.insertAdjacentHTML is not a function
Comment puis-je corriger ce problème?
Merci d'avance.