Does SetAttribute Target=“_top” work in IE7

Discussion in 'JavaScript' started by tonyrocks, Dec 21, 2010.

  1. #1
    I'm pulling in a results set and traversing a div, matching on A href and trying to add SetAttribute = "_top" because I would like to break out of the frame that this result set is sitting in. The following code seems to work in FireFox, but doesn't appear to be working in IE7.

    YAHOO.util.Event.onDOMReady(
    function catlinks(){
    
    var special = YAHOO.util.Dom.getElementsByClassName('special');
    
    for (var i=0 i<special.length;i++){
         var anchors = special[i].getElementsByTagName('a');
             for (var j=0; j<anchors.length; j++){
                 anchors[j].setAttribute('target','_top');
                 }
        }
      }
    )
    Code (markup):

     
    tonyrocks, Dec 21, 2010 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Nope, it should work in IE x/7/8. Link targets have been the standard for as long as I can remember.

    Not sure why it is not working, make sure that you actually retrieve the links (alert/print them).
     
    ThePHPMaster, Dec 22, 2010 IP