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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...