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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...