IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Compatibilité IE -Firefox


Sujet :

JavaScript

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    98
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 98
    Points : 39
    Points
    39
    Par défaut Compatibilité IE -Firefox
    Bonjour,
    j'ai un script que j'utilise pour remplir un textarea depuis une liste.
    Le script fonctionne très bien sous ie mais pas sous firefox.
    Y'aurait-il une adaptation pour que mon code fonctionne aussi bien sous ie que sur les autre navigateurs ?

    Voici le script avec le formulaire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    <script type="text/javascript">
    function ajout_mail(demande)
    { 
    	var ou,rch;
    	for ( var n=0;n<form_mail.select_mail.length;n++ )
    		{
    		if ( form_mail.select_mail[n].selected )
    			{
    			rch=form_mail.select_mail[n].text;
    			ou=form_mail.reception_mail.value.indexOf(rch);
     
    				switch (demande)
    					{
    					case "Ajouter":
    					if ( ou==-1 )
    						{
    						form_mail.reception_mail.value+=rch+"\r\n";
    						}
    						break;
     
    					case "Supprimer":
    					if ( ou>=0 )
    						{ 
    						form_mail.reception_mail.value=form_mail.reception_mail.value.substr(0,ou)+form_mail.reception_mail.value.substr(ou+rch.length+1); 
    						}
    						break;
    					}
    			}
    		}
    }
     
    </script>
     
    <form name="form_mail" action="ajout-affichage.php" method="post" enctype="multipart/form-data"> 
     
    <select name="select_mail" multiple="multiple" style="height:167px">
    <option value="">un@mail.fr</option>
    <option value="">deux@mail.fr</option>
    <option value="">trois@mail.fr</option>
    <option value="">quatre@mail.fr</option>
    <option value="">cinq@mail.fr</option>
    <option value="">six@mail.fr</option>
    <option value="">sept@mail.fr</option>
    </select>
     
     
    <textarea name="reception_mail" cols="50" rows="10"></textarea><br/><br/>
    <input type="button" value="ajouter" onclick="ajout_mail('Ajouter');">
    <input type="button" value="supprimer" onclick="ajout_mail('Supprimer');">
     
    <input name="submit" type="submit" value="Valider" />
    </form>

  2. #2
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Bonjour,
    1-
    for ( var n=0;n<form_mail.select_mail.length;n++ )
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    for ( var n=0;n<document.form_mail.select_mail.length;n++ )
    2- Met les value des options sinon la valeur submiter pour ton select sera vide. Et c'est cette value que tu utilises mais pas text.

    A+.

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    98
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 98
    Points : 39
    Points
    39
    Par défaut
    Bonjour et merci pour l'aide.
    j'ai fais les modification que vous m'avez conseillé mais sa ne fonctionne toujours pas sous firefox.

  4. #4
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Peut-on voir ton code actuel?

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    98
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 98
    Points : 39
    Points
    39
    Par défaut
    oui le voici :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    <script type="text/javascript">
    function ajout_mail(demande)
    { 
    	var ou,rch;
    	for ( var n=0;n<document.form_mail.select_mail.length;n++ )
    		{
    		if ( form_mail.select_mail[n].selected )
    			{
    			rch=form_mail.select_mail[n].text;
    			ou=form_mail.reception_mail.value.indexOf(rch);
     
    				switch (demande)
    					{
    					case "Ajouter":
    					if ( ou==-1 )
    						{
    						form_mail.reception_mail.value+=rch+"\r\n";
    						}
    						break;
     
    					case "Supprimer":
    					if ( ou>=0 )
    						{ 
    						form_mail.reception_mail.value=form_mail.reception_mail.value.substr(0,ou)+form_mail.reception_mail.value.substr(ou+rch.length+1); 
    						}
    						break;
    					}
    			}
    		}
    }
     
    </script>
     
    <form name="form_mail" action="ajout-affichage.php" method="post" enctype="multipart/form-data"> 
     
    <select name="select_mail" multiple="multiple" style="height:167px">
    <option value="un@mail.fr">un@mail.fr</option>
    <option value="deux@mail.fr">deux@mail.fr</option>
    <option value="trois@mail.fr">trois@mail.fr</option>
    <option value="quatre@mail.fr">quatre@mail.fr</option>
    <option value="cinq@mail.fr">cinq@mail.fr</option>
    <option value="six@mail.fr">six@mail.fr</option>
    <option value="sept@mail.fr">sept@mail.fr</option>
    </select>
     
     
    <textarea name="reception_mail" cols="50" rows="10"></textarea><br/><br/>
    <input type="button" value="ajouter" onclick="ajout_mail('Ajouter');">
    <input type="button" value="supprimer" onclick="ajout_mail('Supprimer');">
     
    <input name="submit" type="submit" value="Valider" />
    </form>

  6. #6
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Apparemment tu n'as pas essayer de comprendre le bout de code que j'ai donné.
    1- il faut remplacer les
    form_mail.select_mail
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    document.form_mail.select_mail
    pour acceder au select.
    2- pour acceder aux options
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    document.form_mail.select_mail.options[n]
    D'ailleurs ton code se faire en
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    function ajout_mail(demande)
    { 
    	var rch = document.form_mail.select_mail.value;
    	var ou=document.form_mail.reception_mail.value.indexOf(rch);
    	switch (demande)
    		{
    		case "Ajouter":
    		if ( ou==-1 )
    			{
    			document.form_mail.reception_mail.value+=rch+"\r\n";
    			}
    			break;
     
    		case "Supprimer":
    		if ( ou>=0 )
    			{ 
    			document.form_mail.reception_mail.value=form_mail.reception_mail.value.substr(0,ou)+form_mail.reception_mail.value.substr(ou+rch.length+1); 
    			}
    			break;
    		}
    }
    Vérifie les accès aux éléments du formulaire .

    A+.

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    98
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 98
    Points : 39
    Points
    39
    Par défaut
    Ok merci c'est vrai que je n’avais pas compris (je ne connais pas encore bien js).
    Sa fonctionne maintenant par contre si dans ma page j’intègre TinyMCE (dans mon head) pour faire un peu de mise en page sa ne fonctionne plus à nouveau.

    y'a t-il incompatibilité ?

    le js TINYMCE :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    <!-- TinyMCE -->
    <script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript"> 
    	tinyMCE.init({
    		// General options
    		mode : "textareas",
    		theme : "advanced",
    		editor_deselector : "mceNoEditor",
     
    		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
     
    		// Theme options
    		theme_advanced_buttons1 : "bold,italic,underline,link,unlink,forecolor,backcolor,fontselect,fontsizeselect",
    		theme_advanced_buttons2 : "",
    		theme_advanced_buttons3 : "n",
    		theme_advanced_buttons4 : "",
    		theme_advanced_toolbar_location : "top",
    		theme_advanced_toolbar_align : "left",
    		theme_advanced_statusbar_location : "bottom",
    		theme_advanced_resizing : true,
     
    		// Example content CSS (should be your site CSS)
    		content_css : "css/content.css",
     
    		// Drop lists for link/image/media/template dialogs
    		template_external_list_url : "lists/template_list.js",
    		external_link_list_url : "lists/link_list.js",
    		external_image_list_url : "lists/image_list.js",
    		media_external_list_url : "lists/media_list.js",
     
    		// Style formats
    		style_formats : [
    			{title : 'Bold text', inline : 'b'},
    			{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
    			{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
    			{title : 'Example 1', inline : 'span', classes : 'example1'},
    			{title : 'Example 2', inline : 'span', classes : 'example2'},
    			{title : 'Table styles'},
    			{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
    		],
     
    		// Replace values for the template plugin
    		template_replace_values : {
    			username : "Some User",
    			staffid : "991234"
    		}
    	});
    </script>
    <!-- /TinyMCE -->

  8. #8
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Citation Envoyé par fabrice88 Voir le message
    y'a t-il incompatibilité ?
    Non, par-contre, vérifie bien tes paramètres de tinymce s'ils sont corrects. Utilise Firebug pour voir l'erreur.

    A+.

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    98
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 98
    Points : 39
    Points
    39
    Par défaut
    bon... j'avance plus.
    dès que j’intègre tinymce dans la page ou j'ai le script que l'on vient de voir sa ne fonctionne plus. (pour info indepandemant tinymce fonction bien mais pas en même temps que ce script)
    j'ai installé firebug mais je ne trouve pas d'ou vient le pb.

    voici ma page au complet au cas ou.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Page test</title>
     
     
    <!-- TinyMCE -->
    <script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript"> 
    	tinyMCE.init({
    		// General options
    		mode : "textareas",
    		theme : "advanced",
    		editor_deselector : "mceNoEditor",
     
    		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
     
    		// Theme options
    		theme_advanced_buttons1 : "bold,italic,underline,link,unlink,forecolor,backcolor,fontselect,fontsizeselect",
    		theme_advanced_buttons2 : "",
    		theme_advanced_buttons3 : "n",
    		theme_advanced_buttons4 : "",
    		theme_advanced_toolbar_location : "top",
    		theme_advanced_toolbar_align : "left",
    		theme_advanced_statusbar_location : "bottom",
    		theme_advanced_resizing : true,
     
    		// Example content CSS (should be your site CSS)
    		content_css : "css/content.css",
     
    		// Drop lists for link/image/media/template dialogs
    		template_external_list_url : "lists/template_list.js",
    		external_link_list_url : "lists/link_list.js",
    		external_image_list_url : "lists/image_list.js",
    		media_external_list_url : "lists/media_list.js",
     
    		// Style formats
    		style_formats : [
    			{title : 'Bold text', inline : 'b'},
    			{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
    			{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
    			{title : 'Example 1', inline : 'span', classes : 'example1'},
    			{title : 'Example 2', inline : 'span', classes : 'example2'},
    			{title : 'Table styles'},
    			{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
    		],
     
    		// Replace values for the template plugin
    		template_replace_values : {
    			username : "Some User",
    			staffid : "991234"
    		}
    	});
    </script>
    <!-- /TinyMCE -->
     
    </head>
     
    <body>
     
     
    <script type="text/javascript">
    function ajout_mail(demande)
    { 
    	var rch = document.form_mail.select_mail.value;
    	var ou = document.form_mail.reception_mail.value.indexOf(rch);
    	switch (demande)
    		{
    		case "Ajouter":
    		if ( ou==-1 )
    			{
    			document.form_mail.reception_mail.value+=rch+"\r\n";
    			}
    			break;
     
    		case "Supprimer":
    		if ( ou>=0 )
    			{ 
    			document.form_mail.reception_mail.value=form_mail.reception_mail.value.substr(0,ou)+form_mail.reception_mail.value.substr(ou+rch.length+1); 
    			}
    			break;
    		}
    }
     
    </script>
     
    <form name="form_mail" action="ajout-affichage.php" method="post" enctype="multipart/form-data"> 
    <select name="select_mail" multiple="multiple" style="height:167px">
    <option value="un@mail.fr">un@mail.fr</option>
    <option value="deux@mail.fr">deux@mail.fr</option>
    <option value="trois@mail.fr">trois@mail.fr</option>
    <option value="quatre@mail.fr">quatre@mail.fr</option>
    <option value="cinq@mail.fr">cinq@mail.fr</option>
    <option value="six@mail.fr">six@mail.fr</option>
    <option value="sept@mail.fr">sept@mail.fr</option>
    </select>
     
     
    <textarea name="reception_mail" cols="50" rows="10"></textarea><br/><br/>
    <input type="button" value="ajouter" onclick="ajout_mail('Ajouter');">
    <input type="button" value="supprimer" onclick="ajout_mail('Supprimer');">
     
    <input name="submit" type="submit" value="Valider" />
    </form>
     
    </body>
    </html>

Discussions similaires

  1. Javascrit : Compatibilité IE - Firefox
    Par mariemor64 dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 20/04/2006, 13h45
  2. [DOM] compatibilité IE, FireFox
    Par metalpetsFR dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 18/04/2006, 11h16
  3. compatibilité explorer firefox de new Option(,,,)
    Par reski dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 21/03/2006, 14h16
  4. Probleme de compatibilite IE/Firefox
    Par chiv dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 07/02/2006, 09h02
  5. [FLASH] Probleme compatibilité flash/firefox
    Par Benestcon dans le forum Flash
    Réponses: 4
    Dernier message: 17/10/2005, 14h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo