COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: abcuser on 22 Jun 2015 08:08:17 AM

Title: Cognos Viewer: How to scroll to the top of web page
Post by: abcuser on 22 Jun 2015 08:08:17 AM
Hi,
in Cognos 10.2.1 fixpack 6 Report Studio I created crosstab. In Columns I added Quantity measure and in Rows added ProductItem level.

The output of this report is large report. End user has a requirement that at the bottom of crosstab there should be a link with "go to Top". When clicked on this link web browser should scroll to top of web page, just like if <Home> button would be pressed on keyboard.

I saved attached code to Notepad and save the file with name: test.html and open file in browser (File | Open). Scrolled down to bottom of web page and then clicked on "go to Top" link and browser scrolls to top, so code is working fine in plain HTML document.

Back to Cognos Report Studio. I added "HTML item" object bellow crosstab and copied bellow code in it:

<script>
var gotoTop = function() {
document.body.scrollTop =document.documentElement.scrollTop = 0;
};
</script>
<a href="javascript:;" onclick="gotoTop();">go to Top</a>


Run report and scrolled down to bottom. When I click on "go to Top" link, nothing happens. Any idea how to add javascript code to scroll to top of web page?
Thanks