[Javascript] Problem changing link's href property...

Filipiak, Bob (Contractor) filipiab at atsc.army.mil
Fri Jul 13 12:30:36 CDT 2001


Anthony, don't send attachments to mailing lists since some will
automatically delete without opening because of the threat of viruses. Just
post your code in your message:

<html>
<head>
	<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!-- // swap href in links
//accepts two parameters: href of link calling swap(), and the new url to
swap with.

function swap(swapHref, newHref) {
var docLinks = new Array();
  for (i=0; i < document.links.length; i++) {
   docLinks[i] = document.links[i].href;
//   alert(docLinks[i]);
  }
  for (i=0; i<docLinks.length; i++) {
    if (docLinks[i] == swapHref) {
      document.links[i].href = newHref;
//      alert(newHref);
    }
  }
}
// -->
</script>
</head>

<body>

<a href="test.html" onMouseOver="swap(this.href,
'new.html');">test</a><br><br>
<a href="test2.html" onMouseOver="swap(this.href, 'new2.html');">test2</a>
</body>
</html>

Bob Filipiak (Contractor)
MCP 

-----Original Message-----
From: Anthony E. [mailto:apwebdesign at yahoo.com]
Sent: Friday, July 13, 2001 1:14 PM
To: javascript at LaTech.edu
Subject: RE: [Javascript] Problem changing link's href property...


Let me know if this works for you.



see attached()














--- Chris Nafziger <CNafziger at sauder.com> wrote:
> It didn't help.
> 
> -----Original Message-----
> From: Anthony E. [mailto:apwebdesign at yahoo.com]
> Sent: Thursday, July 12, 2001 7:38 PM
> To: javascript at LaTech.edu
> Subject: Re: [Javascript] Problem changing link's
> href property...
> 
> 
> try 
> 
> document.link.jumpTo.href = '/newpath/file.html';
> 
> 
> 
> --- Chris Nafziger <CNafziger at sauder.com> wrote:
> > I'm having a problem with the function below.  The
> > first two lines do what
> > they are supposed to do just fine.  The third line
> > does manage to change the
> > URL of the link, however it only works if I use
> the
> > ID of zero that you see.
> > If I replace the the zero with the value assigned
> to
> > the link's name
> > property, 'JumpTo', similar to the first two
> > function lines, the error
> > 'document.links.JumpTo' is null or not an object
> > comes up.  Why can't I use
> > the link's name property value for the reference
> > like I did with the images?
> > 
> > 
> > // Function that swaps two images and changes the
> > link URL 
> > // when one of the swatch image's onMouseover
> event
> > fires.
> > 
> > function imageOn(i)
> >     { 
> >     document.images["Unit"].src =
> UnitImages[i].src;
> >     document.images["UnitNumber"].src =
> > UnitNumberImages[i].src;
> >     document.links[0].href = Page[i] 
> >     }
> > 
> > <a href="LinkToPage.asp" name="JumpTo"
> > id="JumpTo">Link</a>
> > 
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > http://www.LaTech.edu/mailman/listinfo/javascript
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20010713/8608f8ed/attachment.htm>


More information about the Javascript mailing list