Menu script plus lien html vers iframe

Fermé
acidburn678 Messages postés 2 Date d'inscription vendredi 20 janvier 2006 Statut Membre Dernière intervention 20 janvier 2006 - 20 janv. 2006 à 00:11
acidburn678 Messages postés 2 Date d'inscription vendredi 20 janvier 2006 Statut Membre Dernière intervention 20 janvier 2006 - 20 janv. 2006 à 12:38
salut a tous voila mon problème :
j'ai un menu en java, et un iframe, mais je ne sais pas comment modifier mon fichier script pour afficher les liens du menu dans mon iframe
merci a tous

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="alain marty">
<meta name="keywords" content="architecture, culture technique, structures legeres">
<meta name="description" content="Le site de l'atelier S9/2006/NEBOUT, Ecole nationale supérieur d'architecture de Montpellier France">
<meta name="robots" content="all">
<title>ATELIER S9 || ENSAM 2006</title>

<link rel="stylesheet" type="text/css" href="styles.css" id="le_style">


<script language="javascript" type="text/javascript" src="scripts.js" ></script>


<style>
td { font: 10px arial; color: #440000; background: #cccccc;
padding-left: 0px; padding-right: 0px; margin-top: 0px; margin-bottom: 0px; align:center; }
</style>
</head>


<body id="thebody">





<div class="nav">
<SCRIPT Language="Javascript">
var menu = new DynamicMenu("Menu1");

menu.addParent("accueil");
menu.addChild("présentation","images/intro.html");
menu.addSousParent("Licence 1","");
menu.addChild("Lien 1","page1.html");
menu.addChild("Lien 2","page2.html");
menu.addSousParent("Node 111","");
menu.addChild("Lien 1","page1.html");

menu.addParent("Licence 1","");
menu.addChild("Lien 1","page1.html");

menu.addParent("Licence 2","");
menu.addChild("Lien 1","page1.html");
menu.addChild("Lien 2","page2.html");


menu.addParent("Licence 3","");
menu.addChild("Projet","");
menu.addChild("Workshop","page2.html");
menu.addChild("Artplastique","page2.html");
menu.addSousParent("Informatique","page2.html");

menu.addChild("Archicad","");
menu.addChild("sketchup","");
menu.addChild("Artlantis","");





</SCRIPT>

</div>
<div class="deco"></div>



<div class="affiche" id="affiche">
<iframe src="images/intro.html" id="vue" width="666" height="500" border="1" frameBorder="0" marginHeight="0" marginWidth="0"></iframe>
</div>



</body>
</html>





LE SCRIPT :

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="left.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="left.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 = "bottom.gif" ;
} else {
objElement.style.display = "none" ;
imgIcon.src = "left.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;
}


function afficher_image( ID )
{ cacher_infos();
document.getElementById( 'vue' ).src = ID;
document.getElementById( 'affiche' ).style.display = "block";
}



et le CSS :

body { background-color: #aaa; }
h1 { font: bold italic 14px arial; letter-spacing: 2px; color: #B4B4B4; padding: 5px; margin-top: 0px; margin-bottom: 0px; }
h2 { font: bold italic 10px arial; color: red; padding: 5px; margin-top: 0px; margin-bottom: 0px; border-top: solid 1px red; }
p { font: 10px arial; color: #B4B4B4; padding-left: 10px; padding-right: 10px; margin-top: 0px; margin-bottom: 5px; }
ul, ol { font: 10px arial; color: #B4B4B4; padding-right: 10px; text-align: left; margin-top: 0px; margin-bottom: 0px; }

a { font: bold italic 10px arial; color: #fff; text-decoration: none; }
a:hover { color: red;}

.menu { margin-left: 0px; margin-right: 0px; display: none; }



.titre { position: absolute;
left: 122px; top: 22px; width: 500x; height: 100px;
padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;}

.nav { position: absolute;
left: 22px; top: 122px; width: 200px;
padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; }

.affiche { position: absolute;
left: 222px; top: 122px;
padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; }
A voir également:

2 réponses

balashov Messages postés 17 Date d'inscription vendredi 13 décembre 2002 Statut Membre Dernière intervention 22 mars 2006 1
20 janv. 2006 à 00:22
Bon, tout va bien!

ton code est carrément indigeste, mais avec quelques notions d'html, et en épurant le tout, on trouve!

tu as dans ton script un passage "ajout des liens" §3:
______________________________________________
//-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>';
_______________________________________________

et bien juste après le OnClick="blablabla", il suffit d'ajouter target=vue avant le ">", ce qui donne:

______________________________________________
function DynamicMenu_addChild(strName,strURL) {
var strTemp = '<A HREF="' + strURL + '"'

+ ' onClick="cancelBubble(arguments[0]);" target=vue>'

+ strName + '</A><BR>';
______________________________________________

et donc si tout se passe bien et si je ne suis pas un gros boulet, ça devrait fonctionner!

{au passage, merci pour le code, ça fait un bail que j'en cherche un comme ça!!}

Bonne nuit!!

Balashov
0
acidburn678 Messages postés 2 Date d'inscription vendredi 20 janvier 2006 Statut Membre Dernière intervention 20 janvier 2006
20 janv. 2006 à 12:38
salut, merci pour le Target ca marche mieux mais ca n'ouvre pas dans l'iframe, ca ouvre les liens vers une autre fenetre.....

ps: les 4 dernieres lignes de mon script ne font pas partis de mon script!

:

function afficher_image( ID )
{ cacher_infos();
document.getElementById( 'vue' ).src = ID;
document.getElementById( 'affiche' ).style.display = "block";
}
0