Dashboards & Visualizations

How do I keep the scrollbar unchanged after the dashboard is automatically refreshed?

bestSplunker
Contributor

I have 6 monitors and one host. I used a multi-screen segmentation to display 6 dashboards. Each dashboard is set to auto refresh.I am using the latest version of google chrome.When I adjust the scrollbar position of each dashboard, the user can see more charts. But when the browser is refreshed, the scroll bar will automatically jump to the top, which makes the chart at the bottom of the browser invisible. How can I solve this problem?I think I can use javascript to solve the issue, I found a js code that needs to add some elements to the body, but it seems that I can't control any elements inside the body tag.

function showInfo(type,code){
        window.location.href = "__URL__/show"+type+"/id/"+code;
    }
    function  Trim(strValue)
    {
        return   strValue.replace(/^s*|s*$/g,"");
    }
    function SetCookie(sName,sValue)
    {
        document.cookie = sName + "=" + escape(sValue);
    }
    function GetCookie(sName)
    {
        var aCookie = document.cookie.split(";");
        for(var i=0; i < aCookie.length; i++)
        {
            var aCrumb = aCookie[i].split("=");
            if(sName == Trim(aCrumb[0]))
            {
                return unescape(aCrumb[1]);
            }
        }
        return null;
    }
    function scrollback()
    {
        if(GetCookie("scroll")!=null){document.body.scrollTop=GetCookie("scroll")}
    }

also need to modify the body:

<body id=body onscroll=SetCookie("scroll",body.scrollTop); onload="scrollback();">

Tags (1)
0 Karma
1 Solution

bestSplunker
Contributor

In the end, I solved this problem, which looks like a browser bug.When I installed two extensions in the google chrome , I found that when I refreshed the dashboard.the scrollbars were no longer reset.When I remove the extension from google chrome, the scrollbar will be reset to the top when the dashboard is refreshed.This seems like a very strange question.I don't know if you have encountered the same problem.So I no longer need js to control the scroll bar here.

View solution in original post

0 Karma

bestSplunker
Contributor

In the end, I solved this problem, which looks like a browser bug.When I installed two extensions in the google chrome , I found that when I refreshed the dashboard.the scrollbars were no longer reset.When I remove the extension from google chrome, the scrollbar will be reset to the top when the dashboard is refreshed.This seems like a very strange question.I don't know if you have encountered the same problem.So I no longer need js to control the scroll bar here.

0 Karma
Get Updates on the Splunk Community!

New Release | Splunk Cloud Platform 10.1.2507

Hello Splunk Community!We are thrilled to announce the General Availability of Splunk Cloud Platform 10.1.2507 ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

&#x1f5e3; You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...

Splunk New Course Releases for a Changing World

Every day, the world feels like it’s moving faster with new technological breakthroughs, AI innovation, and ...