Swap Button image and button text Positions

By | May 16, 2012

One day while doing the design of Summary page for one of the custom entities an unobvious thought came into my mind whether I can swap the positions of Button text and Button image on button control. Also following sage CRM standards I wanted to use the standard AddButton feature only tomake sure all the parameters are getting passed on the next pages. Well  a few lines of Javascript on custom content can do this job very easily for you. Here is the summary.
Actual Output:

Desired output:

Script on Custom content of the screen:
< script for=window event=onload >
var oButtons = document.getElementsByTagName(“A”)
for(i=0;i<=oButtons.length-1;i++)
{
                if(oButtons[i].className==”ButtonItem”)
                {
                                var inhtm = new String(oButtons[i].innerHTML)
                                if(inhtm.search(“Help”)>=0)
                                {
                                                //’Find image and text html
                                                var ImageHTM = oButtons[i-1].innerHTML
                                                var TextHTM = oButtons[i].innerHTML
                                                //Swap
                                                oButtons[i-1].innerHTML = TextHTM;
                                                oButtons[i-1].style.cursor=’default’;
                                                oButtons[i].innerHTML = ImageHTM;
                                                oButtons[i].style.cursor=’default’;
                                }
                }
}
< /script >