Changement de texte à image
Lelouch Lamperouge
-
Dackxes Messages postés 305 Statut Membre -
Dackxes Messages postés 305 Statut Membre -
Bonjour,
voici un bout de mon code
<script>
// JavaScript Document début
var intCount = 0;
//-Fonction d'ajout d'entrées principales-------------------------
function DynamicMenu_addParent(strName) {
var strID = 'P_' + strName;
var strTemp = '<DIV ID="' + strID + '" CLASS="parent"';
strTemp += ' onClick="expandCollapse(this);">';
strTemp += '<IMG SRC="leftmenu-plus.gif" Height="12">';
strTemp += ' ' + strName;
strTemp += '<DIV STYLE="display: none" CLASS="child"></DIV>';
strTemp += '</DIV>';
this.div.innerHTML += strTemp;
this.currentChild = document.getElementById(strID);
}
//-Fonction d'ajout des sous entrées principales-------------------------
function DynamicMenu_addSousParent(strName) {
var strID = 'S_' + strName;
var strTemp = '<DIV ID="' + strID + '" CLASS="parent"';
strTemp += ' onClick="expandCollapse(this);">';
strTemp += '<IMG SRC="leftmenu-plus.gif" Height="12">';
strTemp += ' ' + strName;
strTemp += '<DIV STYLE="display: none" CLASS="child"></DIV>';
strTemp += '</DIV>';
if (document.all) {
this.currentChild.children[1].innerHTML += strTemp;
} else {
this.currentChild.childNodes[2].innerHTML += strTemp;
}
this.currentChild = document.getElementById(strID);
}
//-Fonction d'ajout de liens dans le menu-------------------------
function DynamicMenu_addChild(strName,strURL) {
var strTemp = '<A HREF="' + strURL + '"'
+ ' onClick="cancelBubble(arguments[0]);">'
+ strName + '</A><BR>';
if (document.all) {
this.currentChild.children[1].innerHTML += strTemp;
} else {
this.currentChild.childNodes[2].innerHTML += strTemp;
}
}
//-inhibe la cascade d'évènements au DIV conteneur----------------
function cancelBubble(netEvent) {
if (document.all) {
window.event.cancelBubble = true;
} else {
netEvent.cancelBubble = true;
}
}
//-Contracte ou expanse le menu-----------------------------------
function expandCollapse(objElement) {
var strId = objElement.id;
if (intCount == 0) {
if (document.all) {
var imgIcon = objElement.children[0];
objElement = objElement.children[1];
} else {
var imgIcon = objElement.childNodes[0];
objElement = objElement.childNodes[2];
}
if (objElement.style.display == "none") {
objElement.style.display = "block" ;
imgIcon.src = "leftmenu-minus.gif" ;
} else {
objElement.style.display = "none" ;
imgIcon.src = "leftmenu-plus.gif" ;
}
}
if (strId.substring(0,1) == 'S') {
intCount = 1;
}
if (strId.substring(0,1) == 'P' && intCount == 1) {
intCount = 0;
}
}
//-Fonction de création de menu dynamique-------------------------
function DynamicMenu(strName) {
//var id = "Menu" + intCount++;
var id = strName;
document.write('<DIV Id="' + id + '"></DIV>');
this.div = document.getElementById(id);
this.currentChild = null;
this.addParent = DynamicMenu_addParent;
this.addSousParent = DynamicMenu_addSousParent;
this.addChild = DynamicMenu_addChild;
}
// JavaScript Document fin
</script>
...
<SCRIPT Language="Javascript">
var menu = new DynamicMenu("Menu");
menu.addParent("Introduction");
menu.addChild("Présentation","index_julian.php?page=presentation");
menu.addChild("Associations locales","index_julian.php?page=associations_locales");
menu.addChild("Atelier de travail","index_julian.php?page=atelier_travail");
menu.addSousParent("Agenda");
menu.addChild("Réunion mensuelle","page1.html");
menu.addChild("Salon","page1.html");
menu.addChild("Séminaire","page1.html");
menu.addParent("Projets");
menu.addChild("Présenter un projet","index_julian.php?page=presenter_projet");
menu.addChild("Méthode","index_julian.php?page=methode");
menu.addChild("Créer","index_julian.php?page=creer");
menu.addChild("Développer","index_julian.php?page=developper");
menu.addChild("Investir","index_julian.php?page=investir");
menu.addChild("Transmettre","index_julian.php?page=transmettre");
menu.addChild("Réalisation","index_julian.php?page=realisation");
menu.addParent("Divers . . .");
menu.addChild("Partenaires","index_julian.php?page=partenaires");
menu.addChild("Pressbook","index_julian.php?page=pressbook");
menu.addChild("Qui sommes-nous ?","index_julian.php?page=team");
menu.addSousParent("Adhérer")
menu.addChild("Investisseur","index_julian.php?page=investisseur");
menu.addChild("Dirigeant","index_julian.php?page=dirigeant");
menu.addChild("Créateur","index_julian.php?page=createur");
menu.addChild("Membre participant","index_julian.php?page=membre");
</SCRIPT>
j'aimerais savoir comment mettre des images à la place du texte, car j'ai appris à mettre que texte, j'ai donc envie de changer un peu
Merci
voici un bout de mon code
<script>
// JavaScript Document début
var intCount = 0;
//-Fonction d'ajout d'entrées principales-------------------------
function DynamicMenu_addParent(strName) {
var strID = 'P_' + strName;
var strTemp = '<DIV ID="' + strID + '" CLASS="parent"';
strTemp += ' onClick="expandCollapse(this);">';
strTemp += '<IMG SRC="leftmenu-plus.gif" Height="12">';
strTemp += ' ' + strName;
strTemp += '<DIV STYLE="display: none" CLASS="child"></DIV>';
strTemp += '</DIV>';
this.div.innerHTML += strTemp;
this.currentChild = document.getElementById(strID);
}
//-Fonction d'ajout des sous entrées principales-------------------------
function DynamicMenu_addSousParent(strName) {
var strID = 'S_' + strName;
var strTemp = '<DIV ID="' + strID + '" CLASS="parent"';
strTemp += ' onClick="expandCollapse(this);">';
strTemp += '<IMG SRC="leftmenu-plus.gif" Height="12">';
strTemp += ' ' + strName;
strTemp += '<DIV STYLE="display: none" CLASS="child"></DIV>';
strTemp += '</DIV>';
if (document.all) {
this.currentChild.children[1].innerHTML += strTemp;
} else {
this.currentChild.childNodes[2].innerHTML += strTemp;
}
this.currentChild = document.getElementById(strID);
}
//-Fonction d'ajout de liens dans le menu-------------------------
function DynamicMenu_addChild(strName,strURL) {
var strTemp = '<A HREF="' + strURL + '"'
+ ' onClick="cancelBubble(arguments[0]);">'
+ strName + '</A><BR>';
if (document.all) {
this.currentChild.children[1].innerHTML += strTemp;
} else {
this.currentChild.childNodes[2].innerHTML += strTemp;
}
}
//-inhibe la cascade d'évènements au DIV conteneur----------------
function cancelBubble(netEvent) {
if (document.all) {
window.event.cancelBubble = true;
} else {
netEvent.cancelBubble = true;
}
}
//-Contracte ou expanse le menu-----------------------------------
function expandCollapse(objElement) {
var strId = objElement.id;
if (intCount == 0) {
if (document.all) {
var imgIcon = objElement.children[0];
objElement = objElement.children[1];
} else {
var imgIcon = objElement.childNodes[0];
objElement = objElement.childNodes[2];
}
if (objElement.style.display == "none") {
objElement.style.display = "block" ;
imgIcon.src = "leftmenu-minus.gif" ;
} else {
objElement.style.display = "none" ;
imgIcon.src = "leftmenu-plus.gif" ;
}
}
if (strId.substring(0,1) == 'S') {
intCount = 1;
}
if (strId.substring(0,1) == 'P' && intCount == 1) {
intCount = 0;
}
}
//-Fonction de création de menu dynamique-------------------------
function DynamicMenu(strName) {
//var id = "Menu" + intCount++;
var id = strName;
document.write('<DIV Id="' + id + '"></DIV>');
this.div = document.getElementById(id);
this.currentChild = null;
this.addParent = DynamicMenu_addParent;
this.addSousParent = DynamicMenu_addSousParent;
this.addChild = DynamicMenu_addChild;
}
// JavaScript Document fin
</script>
...
<SCRIPT Language="Javascript">
var menu = new DynamicMenu("Menu");
menu.addParent("Introduction");
menu.addChild("Présentation","index_julian.php?page=presentation");
menu.addChild("Associations locales","index_julian.php?page=associations_locales");
menu.addChild("Atelier de travail","index_julian.php?page=atelier_travail");
menu.addSousParent("Agenda");
menu.addChild("Réunion mensuelle","page1.html");
menu.addChild("Salon","page1.html");
menu.addChild("Séminaire","page1.html");
menu.addParent("Projets");
menu.addChild("Présenter un projet","index_julian.php?page=presenter_projet");
menu.addChild("Méthode","index_julian.php?page=methode");
menu.addChild("Créer","index_julian.php?page=creer");
menu.addChild("Développer","index_julian.php?page=developper");
menu.addChild("Investir","index_julian.php?page=investir");
menu.addChild("Transmettre","index_julian.php?page=transmettre");
menu.addChild("Réalisation","index_julian.php?page=realisation");
menu.addParent("Divers . . .");
menu.addChild("Partenaires","index_julian.php?page=partenaires");
menu.addChild("Pressbook","index_julian.php?page=pressbook");
menu.addChild("Qui sommes-nous ?","index_julian.php?page=team");
menu.addSousParent("Adhérer")
menu.addChild("Investisseur","index_julian.php?page=investisseur");
menu.addChild("Dirigeant","index_julian.php?page=dirigeant");
menu.addChild("Créateur","index_julian.php?page=createur");
menu.addChild("Membre participant","index_julian.php?page=membre");
</SCRIPT>
j'aimerais savoir comment mettre des images à la place du texte, car j'ai appris à mettre que texte, j'ai donc envie de changer un peu
Merci
A voir également:
- Changement de texte à image
- Changement dns - Guide
- Extraire texte d'une image - Guide
- Image iso - Guide
- Changement d'heure - Guide
- Insérer une image dans word sans bouger le texte - Guide
1 réponse
Il n 'y à qu 'a aller sur des sites de tutoriels de Javascript. Tu peux aller sur https://www.toutjavascript.com/main/index.php3 ou encore https://openclassrooms.com/fr/