reading the value of the a tag with javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ongame
    New Member
    • Jan 2010
    • 1

    reading the value of the a tag with javascript

    I published my website and it creates the code below code:

    The url's are not the same, see the marked url's. If I click on the link, I go to the wrong webpage. http://en.wikipedia.org/wiki/The_Football_Association is the right url. I want make a javascript file that reads the A tags and so he can copy the right url on the A HREF.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML lang="en">
    <HEAD>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <LINK HREF="CollapsibleList.css" REL="stylesheet" TYPE="text/css">
    <SCRIPT TYPE="text/javascript" SRC="CollapsibleList.js" ></SCRIPT>
    <TITLE>Documents Wiki Football</TITLE>
    <META NAME="author" CONTENT="UAU106">
    </HEAD>
    <BODY>
    <A NAME="Topofpagedocuments1htm"></A>
    <H2>Documents Wiki Football</H2>
    <H3>Link: <A HREF="Http://en.Wikipedia.Org/wiki/the_football_association">http://en.wikipedia.org/wiki/The_Football_Association</A></H3>
    <HR>
    <P>
    <A HREF="#Topofpagedocuments1htm">Go to Top of This Page</A>|
    <A HREF="Index.Htm">Return to the Contents Page</A><BR><SMALL>
    Created from the Test on 12-1-2010 at 13:41</SMALL></P>
    </BODY>
    </HTML>
    Last edited by Dormilich; Jan 12 '10, 01:25 PM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I’d just copy the correct URL by hand into the href, otherwise you should revise the responsible script.

    Comment

    • onlymukti4u
      New Member
      • Mar 2007
      • 50

      #3
      Code:
      <script type="text/javascript">
      
      function changeLink()
      {
      document.getElementById('MyLink').href="Http://en.Wikipedia.Org/wiki/the_football_association";
      document.getElementById('MyLink').target="_blank";
      }
      </script>
      
      <a id="MyLink" href="http://www.JustaLink.com" onclick="changeLink()">Just A Link</a>
      Last edited by Dormilich; Jan 20 '10, 07:53 AM. Reason: Please use [code] tags when posting code

      Comment

      Working...