Portlet links in new window





8
Date Submitted Mon. Nov. 6th, 2006 9:19 AM
Revision 1 of 1
Scripter Casper42
Tags JavaScript | MDI | Portal | utility
Comments 0 comments
This code is used in an Educational Portal product but can be tweaked to fit your need.

This code adds a small icon next to the title of a 'portlet' that resides on the page. By clicking the portlet title, the portlet usually maximizes within the constraint of the portal template - but the extra icon allows for the portlet to be opened in it's own window.

This simulates an MDI interface.
(REQUIRES PopItUp snippet)

function createUtilityLinks() { 
                if (!document.getElementsByTagName){ return; }

    //Look only in the Portlet Grid for Links
    var portletGrid = document.getElementById('PORTLETGRID');
                var anchors = portletGrid.getElementsByTagName('a');
    //alert(anchors.length)
                // loop through all anchor tags
                var intCount = anchors.length
    var i=0
    for (i=0;i<intCount;i++){
                      var anchor = anchors[i];
                        var link = String(anchor.getAttribute('href'));
      var linkType = link.indexOf("?portlet")
      var strLink = new String(anchor.getAttribute('href'));       
     
      if (linkType>-1 ){
        strLink = strLink + "&style=utility"
        anchor.parentNode.innerHTML =  anchor.parentNode.innerHTML + "&nbsp;<a onClick=\" return popItUp('" + strLink + "','" + anchor.text +"');\" class='externalLink' title='Open this portlet in a floating window'>&nbsp;&nbsp;&nbsp;</a>"
        i=i+1
      }
                }
        }
 

Jeremy Edmiston

Comments

There are currently no comments for this snippet.

Voting