Partage
  • Partager sur Facebook
  • Partager sur Twitter

script incompatible Firefox

    13 janvier 2009 à 11:14:34

    Bonjour!
    j'ai un script js qui affiche du texte défilant verticalement. le problème est que ce dernier ne fonctionne que sur IE, sous firefox tous les textes sont melangés et le défilement ne se ressent pas. je ne sais meme pas si sur d'autres navigateurs c'est pareil. j'aimerai que vous m'aidiez à rendre mon script compatible à tous les navigateurs. et aussi pour faire en sorte que mon texte défile dans un petit cadre.
    <!--
    
    var txt_defil_width = 70; //largeur
    var txt_defil_height = 40; //hauteur
    var txt_defil_bgcolor = '#FFFFFF'; //couleur de fond
    var txt_defil_background = ""; //image de fond
    var txt_defil_pause = 5000; //Temps en milliemes de secondes
    
    var txt_defil_info = new Array;
    
    txt_defil_info[0]='<a href="page1.htm" CLASS=txt_defil>texte1fgfdgrtetrrytuyuyuiuiujhgjhgjhgjhgjghjjgjgtexte1fgfdgrtetrrytuyuyuiuiujhgjhgjhgjhgjghjjgjg</a>non';
    txt_defil_info[1]='<a href="page1.htm" CLASS=txt_defil>1000ghgfhgfhfghfghfghfghfghffhjhjhhgjhjgjhggjhdrtexte1fgfdgrtetrrytuyuyuiuiujhgjhgjhgjhgjghjjgjg</a>oui';
    txt_defil_info[2]='<a href="page1.htm" CLASS=txt_defil>8999bvcbvcbfhgjhgjhjhkjkjkjkjsdfsdsfgsgsgsgsgsgdtexte1fgfdgrtetrrytuyuyuiuiujhgjhgjhgjhgjghjjgjg</a>pas';
    
    function writext(texdef)
    	{
    	document.write(texdef);
    	}
    
    writext('<DIV ID=txt_defil_relativ onMouseOver="txt_defil_stop()" onMouseOut="txt_defil_rstart()" STYLE="position:relative;width:'+txt_defil_width +';height:'+txt_defil_height+';background-color:'+txt_defil_bgcolor+';background-image:url('+txt_defil_background+')">');
    writext('<DIV ID=txt_defil_cadre STYLE="position:absolute;width:'+(txt_defil_width -8)+';height:'+(txt_defil_height-8)+';top:4;left:4;clip:rect(0 '+(txt_defil_width -8)+' '+(txt_defil_height-8)+' 0)">');
    writext('<div id=txt_defiler_1 style="position:absolute;width:'+(txt_defil_width -8)+';left:0;top:0;" CLASS=txt_defil >'+txt_defil_info[0]+'</DIV>');
    writext('<div id=txt_defiler_2 style="position:absolute;width:'+(txt_defil_width -8)+';left:0;top:'+txt_defil_height+';" CLASS=txt_defil >'+txt_defil_info[1]+'</DIV>');
    writext('</DIV></DIV>');
    
    txt_defil_1 =1;
    txt_defil_2 = 0;
    stop_mouss=0;
    
    function txt_defil_f1()
    	{
    	if(txt_defil_1 == 1)
    		{
    		txt_defiler_haut = "txt_defiler_1";
    		txt_defiler_bas = "txt_defiler_2";
    		txt_defil_1 = 0;
    		}
    	else
    		{
    		txt_defiler_bas = "txt_defiler_1";
    		txt_defiler_haut = "txt_defiler_2";
    		txt_defil_1 = 1;
    		}
    	txt_defil_nb_info = txt_defil_info.length-1;
    	if(txt_defil_2 == txt_defil_nb_info)
    		txt_defil_next = 0;
    	else
    		txt_defil_next = txt_defil_2+1;
    	if(document.getElementById)
    		document.getElementById(txt_defiler_bas).innerHTML = txt_defil_info[txt_defil_next];
    	txt_defil_top = 0;
    	if(document.getElementById)
    	move1=setTimeout("txt_defil_f2 ()",txt_defil_pause)
    	}
    
    function txt_defil_f2 ()
    	{
    if (stop_mouss == 0)
    {	
    	txt_defil_top -= 1;
    	document.getElementById(txt_defiler_haut).style.top = txt_defil_top;
    	document.getElementById(txt_defiler_bas).style.top = txt_defil_top+txt_defil_height;
    	if((txt_defil_top+txt_defil_height) > 0)
    	move2=setTimeout("txt_defil_f2 ()",10)
    	else
    		txt_defil_f3()
    }
    else	move1=setTimeout("txt_defil_f2 ()",1000)	
    	}
    
    function txt_defil_f3()
    	{
    	txt_defil_2 = txt_defil_next;
    	txt_defil_f1()
    	}
    function txt_defil_stop()
    	{
    	stop_mouss=1;
    	}
    function txt_defil_rstart()
    	{
    	stop_mouss=0;
    	}	
    window.onload = txt_defil_f1;
    
    //-->
    

    .txt_defil {font-size:11px;font-family:Verdana;color:#abcdef;;text-decoration:none}
    .txt_defil:link {font-size:11px;font-family:Verdana;color:#000000;;text-decoration:none}
    .txt_defil:visited {font-size:11px;font-family:Verdana;color:#FFFFFF;;text-decoration:none}
    .txt_defil:hover {font-size:11px;font-family:Verdana;color:#FFCCFF;;text-decoration:underline}
    

    Merci d'avance!
    • Partager sur Facebook
    • Partager sur Twitter
      13 janvier 2009 à 19:29:45

      - Dans ton CSS tu as doublés plusieurs ";"
      - Document.write c'est mal et ça n'engendre que le mal => Cause possible du bug?
      - Lorsque tu redéfinis une propriété CSS en javascipt concernant une taille, tu dois préciser l'unité, donc: document.getElementById('..').style.top = (..) + 'px'; => Cause propable du bug
      • Partager sur Facebook
      • Partager sur Twitter

      script incompatible Firefox

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
      • Editeur
      • Markdown