Friday, April 26, 2013

Cognos javascript to format color every numeric digits in page



<script>
window.onload=coloring();

function coloring()
{
    var spans = document.getElementsByTagName('span'),
    obj = {};
    var r = /[(]\d+[)]/;   /////////pattern will color every number of pattern: (1234)
    for (var i = 0, l = spans.length; i < l; i++) {
    obj[spans[i].id] = spans[i].textContent || spans[i].innerText;
        if (spans[i].innerText.match(r))    {
          alert( spans[i].innerText);
          spans[i].style.color="#FF0000";
        }
    }
}
</Script>

No comments:

Post a Comment