Append link code

Discussion in 'Javascript' started by LsK_Lele, Aug 6, 2004.

  1. LsK_Lele

    LsK_Lele Guest

    Hello !
    I have a DIV, with a code inside it ...
    I have to append dinamically some HTML code to this code, this code my
    contain links ...
    i tryed:

    oDiv = document.getElementById("MyDiv")
    oDiv.innerHTML = oDiv.innerHTML + "<a href=\"http://www.google.com\"
    target=\"_blank\">http://www.google.com</a>"
    Or
    oDiv.innerHTML = oDiv.innerHTML + '<a href=\"http://www.google.com\"
    target=\"_blank\">http://www.google.com</a>'
    Or
    oDiv.innerHTML = oDiv.innerHTML + "<a href=\x22http://www.google.com\"x22
    target=\x22_blank\x22>http://www.google.com</a>"

    But the window opened by this code does not points to www.google.com, but to
    "http://localhost/www.google.com

    Can someone help me ?
    Thank you very much !
     
    LsK_Lele, Aug 6, 2004
    #1
    1. Advertisements

  2. LsK_Lele

    G Roydor Guest

    essauyez :


    <body>

    <div id="MyDiv">essai</div>


    <br>
    <script>
    oDiv = document.getElementById("MyDiv")
    oDiv.innerHTML = oDiv.innerHTML + "<a href=http://www.google.com
    target=_blank>http://www.google.com</a>"
    </script>



    </body>

    LsK_Lele a écrit:
    > Hello !
    > I have a DIV, with a code inside it ...
    > I have to append dinamically some HTML code to this code, this code my
    > contain links ...
    > i tryed:
    >
    > oDiv = document.getElementById("MyDiv")
    > oDiv.innerHTML = oDiv.innerHTML + "<a href=\"http://www.google.com\"
    > target=\"_blank\">http://www.google.com</a>"
    > Or
    > oDiv.innerHTML = oDiv.innerHTML + '<a href=\"http://www.google.com\"
    > target=\"_blank\">http://www.google.com</a>'
    > Or
    > oDiv.innerHTML = oDiv.innerHTML + "<a href=\x22http://www.google.com\"x22
    > target=\x22_blank\x22>http://www.google.com</a>"
    >
    > But the window opened by this code does not points to www.google.com, but to
    > "http://localhost/www.google.com
    >
    > Can someone help me ?
    > Thank you very much !
    >
    >
     
    G Roydor, Aug 6, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Graham Thomson
    Replies:
    3
    Views:
    640
    Eki Y. Baskoro
    Dec 18, 2003
  2. Rich
    Replies:
    0
    Views:
    799
  3. J.Artieda

    link c code with c++ code using g++

    J.Artieda, Apr 9, 2004, in forum: C Programming
    Replies:
    1
    Views:
    526
  4. HYRY
    Replies:
    10
    Views:
    839
    Bruno Desthuilliers
    Sep 26, 2007
  5. Dave Angel
    Replies:
    4
    Views:
    505
    Piet van Oostrum
    Jul 6, 2009
  6. Ray K.
    Replies:
    1
    Views:
    148
    Robert Klemme
    Jul 23, 2010
  7. HALLES
    Replies:
    17
    Views:
    434
    Thomas 'PointedEars' Lahn
    Jun 2, 2005
  8. pt36
    Replies:
    9
    Views:
    775
    Thomas 'PointedEars' Lahn
    Jul 13, 2008
Loading...