SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    NJ/NY
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to change link address

    I'm really unsure about this, heh. I want to create a javascript function that will change the url of an image link. This is what I tried (which I'm sure is totally wrong):
    HTML Code:
    document.images['myimagename'].onClick = "location.href = '" + address + "'";
    where address is a parameter passed into my function and myimagename is the name of my image.

    Thanks in advance.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Close....
    Code:
    document.images['myimagename'].onclick = new Function('window.location = "' + address + '"');
    Need to use the Function() constructor (assuming there is no <a href="..."> involved....)
    ::: certified wild guess :::

  3. #3
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    NJ/NY
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh cool. Thanks again. I would have never figured that out by myself.. haha.


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
  •