0

There are lot of links in my page. Of which most of them are to be opened in the same tab so, i have set the base target="_top" but For particular columns of link i need to open them in new tab. Please, tell me how to override this html functionality in my vf page.

TIA!!

2
  • Have you set target="_blank" for those link tags and tried?
    – highfive
    Commented Dec 3, 2015 at 10:35
  • yes..but the global html attribute is overriding it..so it is not working as expected Commented Dec 3, 2015 at 10:37

1 Answer 1

1
<div id="tableid">
  <a target='_top' href="something" class="newTabClass"></a>
  <a href="something"> another anchor</a>
  <a href="something"> another anchor</a>
 <a href="something"> another anchor</a>
 </div>

 <script>
    function addTargetTolinks()
    {
        var anchors = document.getElementById('tableid').getElementsByTagName("a");
        for (var i in anchors) {
            if(anchors[i].className != 'newTabClass') 
                 anchors[i].setAttribute("target", "_top");
        }
    }
    addTargetTolinks();
   </script>

By using this you can set the target to all anchor inside tableId except the anchor with newTabClass class

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .