Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Injecting Javascript to One.New Relic Dashboard for Auto Scrolling

javascript
jquery
support

#1

Hi,

We are trying to Inject Javascript to One.New Relic Dashboard for Auto Scrolling. We are getting error while using Jquery.

Code:
function scroll(speed) {
$(‘html, body’).animate({ scrollTop: $(document).height() - $(window).height() }, speed, function() {
$(this).animate({ scrollTop: 0 }, speed);
});
}

speed = 12000;

scroll(speed)
setInterval(function(){scroll(speed)}, speed);

Responses:
Uncaught ReferenceError: $ is not defined
at scrollDown
Uncaught TypeError: el.animate is not a function
at scrollDown

This seems to be a JQuery issues. Could you please help us here.

Thanks


#2

Hey @SSundaram - Can you clarify where you are trying to inject this javascript and how? I’m not sure this is something we can help with, but your answers to that question will help clarify that.


#3

@RyanVeitch Hi, We are using CJS (CustomJavaScript, Chrome Extension) and Snippet in developer tool in Chrome.
We are trying to scroll the Dashboard Automatically from top to bottom and vice versa. So, Injecting the script in Dashboard page.


#4

Hey @SSundaram

That’s not strictly something our support team can advise on - but, my curiosity lead me to trying this myself, and the code worked almost perfectly for me… the only change I had to make was the type of '' you had in your code, from ‘html, body’, to 'html, body'. a subtle change, but an important one for the code to work; full script below.

// Here You can type your custom JavaScript...

function scroll(speed) {
$('html, body').animate({ scrollTop: $(document).height() - $(window).height() }, speed, function() {
$(this).animate({ scrollTop: 0 }, speed);
});
}

speed = 12000;

scroll(speed)
setInterval(function(){scroll(speed)}, speed);

#5

@RyanVeitch thanks for the response. The script works fine with the New Relic In rpm.newrelic.com and insight.newrelic.com but this code does not support in one.newrelic.com. We get this error Uncaught TypeError: Cannot read property ‘height’ of undefined


#6

Hey @SModaraArachchi - thanks for that clarification… I have just tried and experienced the same thing.

I believe this is because of the way dashboards are presented. Where part of the UI is not scrollable;

I’m not 100% sure how to overcome this. You may need to add on to your code to find the scrollable area and jump into that frame (if indeed it is a iframe of sorts) and then attempt to scroll.

However since you can scroll dashboards in Insights, is that a workaround you could use?