Echec Appel à une fonction via une première fonction
Bonjour,
Sauriez-vous m'expliquer pourquoi l'appel à la fonction dénommée "maFonctionAppelee" ne s'opère pas lorsque l'appel se fait depuis la seconde fonction dénommée "maFonctionAppelante" ?
Je vous remercie beaucoup de votre aide.
Voici le script :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <html>
<head>
<script type="text/javascript">
function maFonctionAppelee(a){
alert(a);
}
</script>
</head>
<body>
<a href="javascript:onclick=maFonctionAppelante();">Test VIA maFonctionAppelante</a><br><br>
<a href="javascript:onclick=maFonctionAppelee('test par lien SANS passer par fonction Appelante');">Test par lien SANS passer par maFonctionAppelante</a><br>
<script type="text/javascript">
function maFonctionAppelante(){
let lien = '► <a href="javascript:onclick=maFonctionAppelee(\'test_lien\');">Tester par lien vers maFonctionAppelee</a>';
let alerte = '► <a href="javascript:onclick=alert(\'test_alert\');">Afficher alert</a>';
nouvelle=window.open("","_blank","width=800px,height=600px,scrollbars=yes");
nouvelle.document.write("<center><h2><b>Page test</b></h2>");
nouvelle.document.write("<table style='width:450px;'><tr><th style='width:300px;'></th><th style='width:450px;'></th></tr>");
nouvelle.document.write("<tr><td>lien (ne fonctionne pas)</td><td>" + lien + "</td></tr>");
nouvelle.document.write("<tr><td>alert (fonctionne)</td><td>" + alerte + "</td></tr>");
nouvelle.document.write("</table></center>");
}
</script>
</body>
</html> |