cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

autoscroll a discussion board

Scroll a discussion board

I have a long discussion board that I'd like to autoscroll to the bottom of when I load the page.

I tried setting up an html page with a line of java script, but it looks like Canvas doesn't allow java in html

Are there options for displaying a discussion that would help me?

Is there a way to add java to Canvas html?

Here's what I've tried:

<html>

<p>This is the page...</p>

<p><a href="https://psu.instructure.com/courses/1892239/discussion_topics/120649

94?module_item_id=24723651"> click here </a></p>

<script>window.scrollTo(0,document.body.scrollHeight);</script>

</html>

3 Replies
Community Coach
Community Coach

Hello cjm38@psu.edu...

I am not sure of an answer for you, but I wanted to let you know that I am going to share your question with the Canvas Developers‌ group here in the Canvas Community in hopes that your question will get some additional exposure.  If you are not yet following this group, please use the link that I have provided, and then click on the "Follow" button at the top right corner of the page.  Also, at the top right corner of the page you will find an "Actions" menu.  Click on that, and then choose "Join group".  I hope this will be of some help to you, Chris.  Good luck!

Navigator

cjm38@psu.edu,

I'll start with the explanation of why that code you put in is being removed. JavaScript, in fact any kind of script, is removed from the input before the content is saved. There is a Canvas HTML Editor Whitelist of elements, tags, and attributes that are allowed. Anything else is removed. Scripting is a security risk as it runs with the permissions of the user. If allowed, a student could upload a script into a page that, when viewed by the instructor, made calls and changed grades in the gradebook. Poorly written scripts could adversely affect the performance of Canvas and leaving a bad feeling towards the software when it's the script's fault. 

Canvas does allow custom JavaScript at the account or subaccount level, but not at the course level. This means that a Canvas Admin could add code that would do this, but that it would apply to every course in the account, not just your course (they could add code to make it work with just your course, but then your course has a different experience than all of the other courses, which makes it a bad user experience for the student). Custom JavaScript has to be maintained and checked every three weeks when new releases of Canvas are made to make sure that they still function with the changes that happen in Canvas. There are also considerations such as mobile apps and accessibility that come into play that may make your solution not work. For those reasons and more, most Canvas Admins are unlikely to add custom JavaScript unless it is a major or required functionality they want all courses to have. 

There is a feature idea on Product Radar to https://community.canvaslms.com/ideas/1190-order-discussion-posts-from-newest-to-oldest" modifiedtit.... You may want to go there, read up, provide your use case if not already there, and lend your support by voting for the idea.

Community Coach
Community Coach

Hello once again, cjm38@psu.edu...

I have been reviewing older questions here in the Canvas Community, and I wanted to check in with you.  I noticed that we have not heard back from you since you first posted this question on July 8, 2018.  It looks as though james@richland.edu‌ provided some good feedback to you later that evening.  Have you had an opportunity to review his response?  If so, did his feedback help to answer your question?  Do you have any outstanding questions for Community members as it relates to your original questions?  If you feel that James has helped to answer your question, please feel free to click on the "Mark Correct" button next to his response.  However, if you are still looking for some help with this question, please come back to this thread to post an update so that someone from the Community might be able to assist you.  For the time being, I am going to mark your question as "Assumed Answered" because we have not heard back from you for five months and because there hasn't been any new activity in this topic for about that same amount of time.  However, this will not prevent you or others from posting additional questions and/or comments below that are related to this subject matter.  I hope that's alright with you, Chris.  Looking forward to hearing back from you soon.