- What Grafana version and what operating system are you using?
Version 9.1.0
What are you trying to achieve?
I am trying to get Javascript in a text panel to run on page load.
I am trying to disable the title bar of each panel because the dropdown options really get in the way of using the panel as a button (with data links to other dashboards).
I’ve gotten a Javascript button to successfully hide and unhide the title bars, sooo great! However I am trying to get the same script to run on page load so the user does not have to click a button. I am not having any success here.
I have no Javascript experience, I work in industrial controls, not web development, so if I’m doing something stupid, please be gentle.
Here is what I have. Does anyone have any suggestion on how to get this snippet to run on page load? From all I can find “body onload” should have done it.
<body onload="TOGGLER();">
<br>
<br>
<input type="button" onclick="TOGGLER()" value="Button" id="toggler-button"/>
<script type="text/javascript">
var TOGGLE = 0
function TOGGLER() {
TOGGLE = TOGGLE ^ 1
if (TOGGLE == 1){
document.getElementsByClassName('panel-header')[0].style.visibility = 'hidden';
[].forEach.call(document.querySelectorAll('.panel-header'), function (el) {
el.style.visibility = 'hidden';});
document.getElementById('toggler-button').value='In Run Mode';
document.getElementById('toggler-button').style.backgroundColor='Green';
}
else{
document.getElementsByClassName('panel-header')[0].style.visibility = 'visible';
[].forEach.call(document.querySelectorAll('.panel-header'), function (el) {
el.style.visibility = 'visible';});
document.getElementById('toggler-button').value='In Edit Mode';
document.getElementById('toggler-button').style.backgroundColor='Red';
}
}
</script>
</body>
Thanks!