href attribute

Discussion in 'Javascript' started by UKuser, Feb 20, 2008.

  1. UKuser

    UKuser Guest

    Hi,

    I'm having problems with this line:

    document.getElementById('link'+1).setAttribute('href','#');
    where link+1 is
    <a href="map.html" target="searchX" id='link1'>Images</a>

    Unlike many posts I've found on the web, I actually need to amend
    link1 rather than create it. The reason being is that I've created
    some tabs where if javascript is not turned on the search outputs to
    an iframe hidden in the noscript tag. In FF I can strip the map.html
    so it will work normally with JS turned on however IE still opens
    map.html in a new window - showing its not stripping the href.

    Any help would be great.

    Thanks

    A
     
    UKuser, Feb 20, 2008
    #1
    1. Advertising

  2. UKuser

    SAM Guest

    UKuser a écrit :
    > Hi,
    >
    > I'm having problems with this line:
    >
    > document.getElementById('link'+1).setAttribute('href','#');


    document.getElementById('link'+1).href = '#';

    --
    sm
     
    SAM, Feb 20, 2008
    #2
    1. Advertising

  3. UKuser

    UKuser Guest

    On Feb 20, 3:56 pm, SAM <>
    wrote:
    > UKuser a écrit :
    >
    > > Hi,

    >
    > > I'm having problems with this line:

    >
    > > document.getElementById('link'+1).setAttribute('href','#');

    >
    > document.getElementById('link'+1).href = '#';
    >
    > --
    > sm


    Thanks for replying.

    In the end I actually used removeAttribute - which I'd played with on
    the target attribute but it didnt fully work - never tried it on href
    and that fixed it.

    Thanks again.

    A
     
    UKuser, Feb 20, 2008
    #3
  4. UKuser

    SAM Guest

    UKuser a écrit :
    > On Feb 20, 3:56 pm, SAM <>
    > wrote:
    >> UKuser a écrit :
    >>
    >>> I'm having problems with this line:
    >>> document.getElementById('link'+1).setAttribute('href','#');

    >> document.getElementById('link'+1).href = '#';

    >
    > Thanks for replying.
    >
    > never tried it on href and that fixed it.


    Probably :
    document.links['link'+1].href = '#';
    would have fixed it too.

    --
    sm
     
    SAM, Feb 20, 2008
    #4
  5. UKuser

    David Mark Guest

    On Feb 20, 10:34 am, UKuser <> wrote:
    > Hi,
    >
    > I'm having problems with this line:
    >
    > document.getElementById('link'+1).setAttribute('href','#');
    > where link+1 is
    > <a href="map.html" target="searchX" id='link1'>Images</a>
    >
    > Unlike many posts I've found on the web, I actually need to amend
    > link1 rather than create it. The reason being is that I've created
    > some tabs where if javascript is not turned on the search outputs to
    > an iframe hidden in the noscript tag. In FF I can strip the map.html
    > so it will work normally with JS turned on however IE still opens
    > map.html in a new window - showing its not stripping the href.


    Why not just prevent the default action in the attached listener.
    Changing the href is an odd way to go about this.
     
    David Mark, Feb 21, 2008
    #5
    1. Advertising

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. CRON
    Replies:
    24
    Views:
    203,805
    Adrienne Boswell
    Jun 20, 2006
  2. Soren Vejrum
    Replies:
    4
    Views:
    766
    Lasse Reichstein Nielsen
    Jul 5, 2003
  3. saiho.yuen
    Replies:
    3
    Views:
    552
    kaeli
    Sep 14, 2004
  4. Replies:
    2
    Views:
    634
  5. Vincent van Beveren

    BASE HREF and A HREF="#" onclick="..."

    Vincent van Beveren, Jul 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    430
    Vincent van Beveren
    Jul 6, 2006
Loading...

Share This Page