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 :

[DOM] utilisation d'une variable


Sujet :

JavaScript

  1. #1
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut [DOM] utilisation d'une variable
    Bonjour, je vopoudrai utiliser la variable vrLunnatickImgMongolfiere dans cette ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
       document.write('<img src="vrLunnatickImgMongolfiere" style="border:0px" name="tete" alt="Cliquez ici pour faire disparaître" />');
    mais la ca ne marche pas, que dois-je faire ?

  2. #2
    Rédacteur
    Avatar de bigboomshakala
    Homme Profil pro
    Consultant Web .NET
    Inscrit en
    Avril 2004
    Messages
    2 077
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Consultant Web .NET
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2004
    Messages : 2 077
    Points : 2 757
    Points
    2 757
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
       document.write("<img src=\"" + vrLunnatickImgMongolfiere + "\" style=\"border:0px\" name=\"tete\" alt=\"Cliquez ici pour faire disparaître\" />");

  3. #3
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    Bonjour et merci beaucoup

  4. #4
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 665
    Points
    66 665
    Billets dans le blog
    1
    Par défaut
    Koko depuis le temps que l'on te le dit tu devrais te pencher sur le DOM ...
    parce que créer une image avec document.write ...

  5. #5
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    c'est un script que j'ai récupérer je ne l'est pas écrir, le script complet faite qu'une image sui le curseur

  6. #6
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 665
    Points
    66 665
    Billets dans le blog
    1
    Par défaut
    et alors y'a pour dix minutes à l'adapter pour en faire un code propre avec
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    document.createElement('img')

  7. #7
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    si je modifi le script ne marche plu

  8. #8
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 665
    Points
    66 665
    Billets dans le blog
    1
    Par défaut
    forcément il faut tout modifier en conséquence ...

    fait peter le script que je regarde ça ...

  9. #9
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    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
     
     
    /*
    Image qui suit et regarde la souris
    RIPT EDITE SUR L'EDITEUR JAVASCRIPT
     
    */
    var x = 0;
    var y = 0;
     
    if (document.getElementById)
       {
       if(navigator.appName.substring(0,3) == "Net")
          document.captureEvents(Event.MOUSEMOVE);
       document.onmousemove = Pos_Souris;
       window.onload = Bouge_Image;
       }
     
    function Pos_Souris(e)
       {
       x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
       y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
       }
     
    posX = 0;
    posY = 0;
    anim = true;
    oldpos =vrDomainLunnatick + 'images/m1.gif';
     
    function Bouge_Image()
       {
       if (document.getElementById && anim)
          {
          posX = posX+(((x-posX)+20)/15);
          posY = posY+(((y-posY)+20)/15);
          if(posX<x)
             newpos=vrDomainLunnatick + 'images/m1.gif';
          else
             newpos=vrDomainLunnatick + 'images/m1.gif';
    	  if(newpos!=oldpos)
    	  	{
    		document.tete.src=newpos;
    		oldpos=newpos;
    		}
          document.getElementById("teteronde").style.top = posY+"px";
          document.getElementById("teteronde").style.left = posX+"px";
          tempo = setTimeout("Bouge_Image()", 15)
          }
       }
     
    if(document.getElementById)
       {
       document.write('<div id="teteronde" style="position: absolute">');
       document.write("<img src=\"" + vrLunnatickImgMongolfiere + "\" style=\"border:0px\" name=\"tete\" alt=\"Cliquez ici pour faire disparaître\" />");
       document.write('</a>');
       document.write('</div>');
       }

  10. #10
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 665
    Points
    66 665
    Billets dans le blog
    1
    Par défaut
    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
     
    <html>
    <head>
     
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
     
    <script type='text/javascript'>
    /*
    Image qui suit et regarde la souris
    */
    var x = 0;
    var y = 0;
       var vrLunnatickImgMongolfiere =''
       vrDomainLunnatick=''
    if (document.getElementById)
       {
       if(navigator.appName.substring(0,3) == "Net")
          document.captureEvents(Event.MOUSEMOVE);
       document.onmousemove = Pos_Souris;
     
       }
     
    function Pos_Souris(e)
       {
       x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
       y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
       }
     
    posX = 0;
    posY = 0;
    anim = true;
    oldpos =vrDomainLunnatick + 'images/m1.gif';
     
    function Bouge_Image()
       {
       if (document.getElementById && anim)
          {
          posX = posX+(((x-posX)+20)/15);
          posY = posY+(((y-posY)+20)/15);
          if(posX<x)
             newpos=vrDomainLunnatick + 'images/m1.gif';
          else
             newpos=vrDomainLunnatick + 'images/m1.gif';
    	  if(newpos!=oldpos)
    	  	{
    		document.tete.src=newpos;
    		oldpos=newpos;
    		}
          document.getElementById("teteronde").style.top = posY+"px";
          document.getElementById("teteronde").style.left = posX+"px";
          tempo = setTimeout("Bouge_Image()", 15)
          }
       }
     
    function init()
    //if(document.getElementById)
       {
       var TRonde=document.createElement('div');
       TRonde.style.position="absolute";
       TRonde.id="teteronde"
       var Pic=document.createElement('<img name="tete" />');
       Pic.src=vrLunnatickImgMongolfiere;
       Pic.style.border="0";
       Pic.alt="Cliquez ici pour faire disparaître"
       TRonde.appendChild(Pic);
       document.body.appendChild(TRonde);
      Bouge_Image()
       }
    </script>
    </head>
    <body onload="init()">
    </body>
     
    </html>

  11. #11
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    merci beaucoup

  12. #12
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    maintenant je voudrai utiliser la variable dans un lien html:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    &lt;a href=\"" + vrDomainLunnatick + "\"&gt; &lt;img src=\"" + vrDomainLunnatick + "images/ban-pub-site.jpg\" /&gt; &lt;/a&gt;"
    pourrait tu m'aider ?

  13. #13
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    j'ai trouver:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    &lt;a href="
                          <script language="javascript"> document.write(vrDomainLunnatick); </script>
                          " target&quot;blank&quot; &gt; &lt;img src="
                          <script language="javascript"> document.write(vrDomainLunnatick); </script>
                        images/ban-pub-site.jpg" /&gt; &lt;/a&gt;"

  14. #14
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 665
    Points
    66 665
    Billets dans le blog
    1

  15. #15
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    ok merci encore

  16. #16
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    Citation Envoyé par SpaceFrog Voir le message
    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
     
    <html>
    <head>
     
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
     
    <script type='text/javascript'>
    /*
    Image qui suit et regarde la souris
    */
    var x = 0;
    var y = 0;
       var vrLunnatickImgMongolfiere =''
       vrDomainLunnatick=''
    if (document.getElementById)
       {
       if(navigator.appName.substring(0,3) == "Net")
          document.captureEvents(Event.MOUSEMOVE);
       document.onmousemove = Pos_Souris;
     
       }
     
    function Pos_Souris(e)
       {
       x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
       y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
       }
     
    posX = 0;
    posY = 0;
    anim = true;
    oldpos =vrDomainLunnatick + 'images/m1.gif';
     
    function Bouge_Image()
       {
       if (document.getElementById && anim)
          {
          posX = posX+(((x-posX)+20)/15);
          posY = posY+(((y-posY)+20)/15);
          if(posX<x)
             newpos=vrDomainLunnatick + 'images/m1.gif';
          else
             newpos=vrDomainLunnatick + 'images/m1.gif';
    	  if(newpos!=oldpos)
    	  	{
    		document.tete.src=newpos;
    		oldpos=newpos;
    		}
          document.getElementById("teteronde").style.top = posY+"px";
          document.getElementById("teteronde").style.left = posX+"px";
          tempo = setTimeout("Bouge_Image()", 15)
          }
       }
     
    function init()
    //if(document.getElementById)
       {
       var TRonde=document.createElement('div');
       TRonde.style.position="absolute";
       TRonde.id="teteronde"
       var Pic=document.createElement('<img name="tete" />');
       Pic.src=vrLunnatickImgMongolfiere;
       Pic.style.border="0";
       Pic.alt="Cliquez ici pour faire disparaître"
       TRonde.appendChild(Pic);
       document.body.appendChild(TRonde);
      Bouge_Image()
       }
    </script>
    </head>
    <body onload="init()">
    </body>
     
    </html>

    Comme ceci ca ne marche plu dans IE

  17. #17
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    bizzarement ce lien de marche pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <a href="<script language="javascript"> document.createElement(vrDomainLunnatick); </script>/phpBB2/viewforum.php?f=25">vous pouvez me le demander</a>
    qu'est ce qui cloche ?

  18. #18
    Rédacteur
    Avatar de bigboomshakala
    Homme Profil pro
    Consultant Web .NET
    Inscrit en
    Avril 2004
    Messages
    2 077
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Consultant Web .NET
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2004
    Messages : 2 077
    Points : 2 757
    Points
    2 757
    Par défaut
    Citation Envoyé par koKoTis Voir le message
    bizzarement ce lien de marche pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <a href="<script language="javascript"> document.createElement(vrDomainLunnatick); </script>/phpBB2/viewforum.php?f=25">vous pouvez me le demander</a>
    qu'est ce qui cloche ?
    à peu près tout en fait
    dans un href tu mets soit une url (href = "http://www.google.com"), soit du javascript (href = "javascript:alert('toto')")

    là tu as mis une balise script suivi d'un morceau d'url... et pour finir une mauvaise utilisation des double-quote

  19. #19
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    pour ten sur une autre page ca marche

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Utilisation d'une Variable(Vb) dans d'autre language
    Par cach dans le forum VB 6 et antérieur
    Réponses: 5
    Dernier message: 22/02/2005, 12h00
  2. Pl/SQL utilisation d'une variable dans un select
    Par larg dans le forum PL/SQL
    Réponses: 17
    Dernier message: 30/11/2004, 17h08
  3. utilisation d'une variable globale
    Par ZZ dans le forum ASP
    Réponses: 3
    Dernier message: 03/12/2003, 19h11
  4. Utilisation d'une variable sur plusieurs unités
    Par Yamaneko dans le forum Langage
    Réponses: 2
    Dernier message: 05/06/2003, 11h23
  5. Réponses: 4
    Dernier message: 05/06/2002, 14h35

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