If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

scrollTop always returns 0

Started by RickJ, 23 Aug 2013 12:52:31 PM

Previous topic - Next topic

RickJ

Hello all!

I'm not sure if anyone can help with this but I'm trying to implement some fancy tool tips on my report prompt pages. Unfortunately when the page is scrolled it requires the user of the scrollUp call to determine how far so it can augment the tool tip location. However no matter what I do it always seems to return 0.

Any ideas?

This is what I've used for testing:
(Code is copied from a google search I made)
<script type="text/javascript">
function getScrollingPosition()
{
var position = [0, 0];
if (typeof window.pageYOffset != 'undefined')
{
position = [
window.pageXOffset,
window.pageYOffset
];
}
else if (typeof document.documentElement.scrollTop
!= 'undefined' && document.documentElement.scrollTop > 0)
{
position = [
document.documentElement.scrollLeft,
document.documentElement.scrollTop
];
}
else if (typeof document.body.scrollTop != 'undefined')
{
position = [
document.body.scrollLeft,
document.body.scrollTop
];
}
alert(position);
}
</script>
<button type="button" onclick="getScrollingPosition()">Click me!</button>

RickJ

I'm not sure if anyone will ever actually have this issue but I did manage to solve the problem through quite a few hours of investigation.

Long story short, I suspected the page (since it is generated) was contained in some tag/element which is why the body/window values were always 0. I cycled through all the tags and found one that seems to solve the problem for my install. I tested on a number of pages and it seems to hold true consistently.

document.getElementById('RVContentRS').scrollTop

Basically the element RVContentRS is a DIV that contains the entire page.

CognosPaul

I've had a similar problem, and found a slightly different solution. I'll post it when I get back to that client.

You should know that the RVContentRS will probably change based on where you're running the report. While I'm not at a Cognos install at the moment, I think it's extremely likely that running it from the Cognos Connection will change that to RVContent_NS_. You can get around that by doing something like:


var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) 
{

    fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );

}
var preFix = "";
if (fW.elements["cv.id"])
{

    preFix = fW.elements["cv.id"].value;

}   
var nameSpace = "oCV" + preFix;
alert(document.getElementById('RVContent'+preFix).scrollTop);