Javascript scrollIntoView not working correctly

Jun 21, 2023

Hi so I'm trying to recreate this:
https://www.youtube.com/watch?v=c_WjEe0qzUo&feature=youtu.be

I've changed the javascript to all be on one line but regardless it doesn't work correctly like it does in the video and I don't understand why. It just somewhat scrolls down not even to the objects that it supposed to.

The thing is that when I execute the script in the console while having the published file open it works correctly. Can anyone tell me why this is happening? I've attached my storyline file for reference.

 

Edit:

My issue ended up being that the buttons that you click cannot be in the scroll box they have to be outside/floating on top of it otherwise the script won't work properly.

5 Replies
Zachary Mehalick

If you scroll down further in the scroll box you'll see that there's similarly colored boxes that have the requisite "Alternate Text". The colored boxes at the top should scroll to each one of the similar color below. Otherwise the published file wouldn't have them doing anything at all rather than just slightly scrolling downwards.

Norah Berry
Zachary Mehalick

Hi so I'm trying to recreate this:
https://www.youtube.com/watch?v=c_WjEe0qzUo&feature=youtu.be five nights at freddy's

I've changed the javascript to all be on one line but regardless it doesn't work correctly like it does in the video and I don't understand why. It just somewhat scrolls down not even to the objects that it supposed to.

The thing is that when I execute the script in the console while having the published file open it works correctly. Can anyone tell me why this is happening? I've attached my storyline file for reference.

 

Edit:

My issue ended up being that the buttons that you click cannot be in the scroll box they have to be outside/floating on top of it otherwise the script won't work properly.

Open the browser's developer console (usually by pressing F12) and look for any error messages that might indicate issues with your JavaScript code.
These error messages can provide valuable clues about syntax errors, variable scope problems, or other issues preventing the code from working as expected.

Use browser developer tools to set breakpoints in your code and step through it line by line. This can help you see what values are being assigned to variables and how the code is executing.
Consider using a debugging library like console.log statements to print intermediate values and trace the script's execution flow to identify where things are going wrong.