SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Help me ???

  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help me ???

    MY codes:


    <html>
    <head>


    <link href="fd.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript">

    var all_links = document.getElementsByTagName('a');
    var sitepoint_link = all_links[0];

    sitepoint_link.href = "http://www.google.com/";
    </script>


    </head>









    <body>


    <div id="codesection">
    <p id="codepara">
    </p>
    <ul>
    <li><a href="http://www.sitepoint.com/" id="splink"
    >SitePoint</a></li>
    <li><a href="http://www.yahoo.com/" id="yalink"
    >Yahoo!</a></li>
    </ul>
    </div>



    </body>
    </html>



    Question: Why the link splink hasn't been changed? Something wrong??

  2. #2
    SitePoint Addict dnordstrom's Avatar
    Join Date
    Jul 2006
    Location
    Amsterdam
    Posts
    337
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    I haven't checked the syntax or other Javascript errors but at a glance, I'd say put the code before </body> or put it in a function that runs when the document has been loaded. Right now, it looks like the link doesn't exist when the code is run.
    Daniel Nordstrom. of. Nintera(ctive)
    -- Featured post: Part 2. Writing NI.JS JavaScript
    ----- Follow me on Twitter. Got project? Contact me.
    -------- SitePoint: Community Guidelines Be A Great Member


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •