Dymanic Header Color For your Webparts


Dymanic Header Color For your Webparts

Paste the below script on your Content Editor Webpart, put this webpart in the footer zone. All webparts will render based on the color specified in the Array order.

  1. <script type=”text/javascript”>
  2. var bcol=new Array(“#E18B6B”, “#F665AB”, “orange”, “rose”, “blue”);
  3. var rcnt=0;
  4. var x= document.getElementsByTagName(“TD”);
  5. for(var i=0;i<x.length;i++)
  6. {
  7. if(x[i].title !=”Forums” && x[i].title !=””)
  8. {
  9. if(rcnt == 5)
  10. rcnt=0;
  11. var td =x[i];
  12. var row =td.parentNode;
  13. for (var j = 0, col; col = row.cells[j]; j ++) {
  14.     col.style.backgroundColor =bcol[rcnt];
  15.    }
  16. td.parentNode.style.backgroundColor =bcol[rcnt];
  17. td.style.backgroundColor=bcol[rcnt];
  18. rcnt =rcnt +1;
  19. }
  20. }</script>
Advertisements

About sharepointsriram

9+ Yrs of IT experience
This entry was posted in Sharepoint 2010 Web Parts. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s