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>

Thursday, April 25, 2013

JavaScript function to call another link in background applicable to Cognos too


<div id="bgFrame"></div>

<script type="text/javascript">
setTimeout(prepareiFrame,100);
function prepareiFrame() {
bgifrm = document.createElement("IFRAME");
document.getElementById("bgFrame").appendChild(bgifrm );
bgifrm.style.display="none";
bgifrm.setAttribute("src", " http://10.11.11.181:5050/Default.aspx?UserName=Cognos");
}
 </script>

JavaScript function to place div above another object


<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" -->
<script type="text/javascript" language="javascript">

function show_hide_functiondf()
{
if(document.all("MyDivdf").style. visibility =="visible")
{
document.all("MyDivdf").style. visibility ="hidden";
}
else
{
document.all("MyDivdf").style. visibility ="visible";
}
}
</Script>

<html>
<head>
<body>
<input id="Button1" type="button" value="Select Date" onclick="show_hide_functiondf()" />
</br>
<Div id="MyDivdf" style="visibility : hidden; position: absolute; border : red 3px solid; background: green">
Above
</Div>
Bottom
</body>
</head>
</html>