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!!

  • Have you set target="_blank" for those link tags and tried? – highfive Dec 3 '15 at 10:35
  • yes..but the global html attribute is overriding it..so it is not working as expected – Krishna Bidwai Dec 3 '15 at 10:37
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.