Achetez et vendez votre matériel multimédia d'occasion sur notre service de petites annonces informatiques gratuites

Conflit entre deux fichiers .js [Résolu]

Forum informatique > Aide création et gestion de site > Conflit entre deux fichiers .js [Résolu]

<<<1>>>

[Page 1 sur 1 - 4 messages]
Informations Messages

bustaflexx

Avatar de bustaflexx
13 messages
Barrette de RAM
Barrette de RAM

Lien direct Le 28 Décembre 2009 à 02h43

Bonjour,

Le deux scripts marchent tout à fait quand ils sont séparés.
Par contre, une fois mis ensembles, l'un des deux ne fonctionne pas.
J'ai un peu cherché et il semble que c'est un problème avec les deux onload.
J'ai essayé window.onload= {Tabs.Init; LoadJS;}
Mais ça ne marche pas non plus
Any idea please

Ci-bas les deux scripts lib.js et tabs.js

Code



// Bibliothèque Objet
function Ident(Obj){ return (document.all)?document.all[Obj]:document.getElementById(Obj); }
function posX(Obj){ return (Obj.offsetParent)?(Obj.offsetLeft + posX(Obj.offsetParent)):(Obj.offsetLeft); }
function posY(Obj){ return (Obj.offsetParent)?(Obj.offsetTop + posY(Obj.offsetParent)):(Obj.offsetTop); }
function posW(Obj){ return (Obj.offsetParent)?(Obj.offsetWidth + posX(Obj.offsetParent)):(Obj.offsetWidth); }
function posH(Obj){ return (Obj.offsetParent)?(Obj.offsetHeight + posY(Obj.offsetParent)):(Obj.offsetHeight); }

// Détection du click sur menuLeft
function menuDynam(){
for(m=1; m<5; m++){
if(document.all){
Ident('menu'+m).onmousedown=thisMenu;
}else{
Ident('menu'+m).addEventListener("mousedown",thisMenu, false);
}
}
}
function thisMenu(e){ devl('s'+this.id); }


// fonction pour réglementation de l'attribut 'target' du W3C
function TargetBlank() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
}
}


// Fonction menu developpent
function devl(id) {
var d = Ident(id), e=false;
if(d){ if(d.style.display=='block') e=true; }
for (var i = 1; i<=10; i++) {
if (Ident('smenu'+i)) {Ident('smenu'+i).style.display='none';}
}
if(d){
d.style.display=(e==false)?'block':'none';
}
}

function LoadJS(){
TargetBlank();
devl();
menuDynam();
}

// Executer la fonction
window.onload=LoadJS;



Code

// CSS helper functions
CSS = {
// Adds a class to an element.
AddClass: function (e, c) {
if (!e.className.match(new RegExp("\\b" + c + "\\b", "i")))
e.className += (e.className ? " " : "") + c;
},

// Removes a class from an element.
RemoveClass: function (e, c) {
e.className = e.className.replace(new RegExp(" \\b" + c + "\\b|\\b" + c + "\\b ?", "gi"), "");
}
};

// Functions for handling tabs.
Tabs = {
// Changes to the tab with the specified ID.
GoTo: function (contentId, skipReplace) {
// This variable will be true if a tab for the specified
// content ID was found.
var foundTab = false;

// Get the TOC element.
var toc = document.getElementById("toc");
if (toc) {
var lis = toc.getElementsByTagName("li");
for (var j = 0; j < lis.length; j++) {
var li = lis[j];

// Give the current tab link the class "current" and
// remove the class from any other TOC links.
var anchors = li.getElementsByTagName("a");
for (var k = 0; k < anchors.length; k++) {
if (anchors[k].hash == "#" + contentId) {
CSS.AddClass(li, "current");
foundTab = true;
break;
} else {
CSS.RemoveClass(li, "current");
}
}
}
}

// Show the content with the specified ID.
var divsToHide = [];
var divs = document.getElementsByTagName("div");
for (var i = 0; i < divs.length; i++) {
var div = divs[i];

if (div.className.match(/\bcontent\b/i)) {
if (div.id == "_" + contentId)
div.style.display = "block";
else
divsToHide.push(div);
}
}

// Hide the other content boxes.
for (var i = 0; i < divsToHide.length; i++)
divsToHide[i].style.display = "none";

// Change the address bar.
if (!skipReplace) window.location.replace("#" + contentId);
},

OnClickHandler: function (e) {
// Stop the event (to stop it from scrolling or
// making an entry in the history).
if (!e) e = window.event;
if (e.preventDefault) e.preventDefault(); else e.returnValue = false;

// Get the name of the anchor of the link that was clicked.
Tabs.GoTo(this.hash.substring(1));
},

Init: function () {
if (!document.getElementsByTagName) return;

// Attach an onclick event to all the anchor links on the page.
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++) {
var a = anchors[i];
if (a.hash) a.onclick = Tabs.OnClickHandler;
}

var contentId;
if (window.location.hash) contentId = window.location.hash.substring(1);

var divs = document.getElementsByTagName("div");
for (var i = 0; i < divs.length; i++) {
var div = divs[i];

if (div.className.match(/\bcontent\b/i)) {
if (!contentId) contentId = div.id;
div.id = "_" + div.id;
}
}

if (contentId) Tabs.GoTo(contentId, true);
}
};

// Hook up the OnLoad event to the tab initialization function.
window.onload = Tabs.Init;

// Hide the content while waiting for the onload event to trigger.
var contentId = window.location.hash || "#Introduction";

if (document.createStyleSheet) {
var style = document.createStyleSheet();
style.addRule("div.content", "display: none;");
style.addRule("div" + contentId, "display: block;");
} else {
var head = document.getElementsByTagName("head")[0];
if (head) {
var style = document.createElement("style");
style.setAttribute("type", "text/css");
style.appendChild(document.createTextNode("div.content { display: none; }"));
style.appendChild(document.createTextNode("div" + contentId + " { display: block; }"));
head.appendChild(style);
}
}

 

JU571N

Avatar de JU571N
652 messages
Carte Mère
Carte Mère
AidoWindows
AidoWindows

Lien direct Le 20 Février 2010 à 08h37

Bonjour,

un petit tuto Sourire

Bonne journée

De retour :P ; retrouvez moi sur http://www.siteduzero.com/membres-294-229327.html
 

bustaflexx

Avatar de bustaflexx
13 messages
Barrette de RAM
Barrette de RAM

Lien direct Le 20 Février 2010 à 16h05

Merci beaucoup, problème résoluSourire

 

JU571N

Avatar de JU571N
652 messages
Carte Mère
Carte Mère
AidoWindows
AidoWindows

Lien direct Le 21 Février 2010 à 14h49

de rien Clin d'oeil , met en résolu avec la flèche verte en haut de ton post

De retour :P ; retrouvez moi sur http://www.siteduzero.com/membres-294-229327.html
 

<<<1>>>

[Page 1 sur 1 - 4 messages]

Forum informatique > Aide création et gestion de site > Conflit entre deux fichiers .js [Résolu]