• Hello,

    I have a scrolling window on a website I am building, this scrolling window is used for instant messaging. The scroll bar automatically goes to the top when I click a send message button. Ideally, I want the scroll bar to always go to the bottom, every time a message is sent. Does anyone know if the defauly scroller position can be set using CSS.

    Any help is much appreciated.

    Kind regards,

    Jamie

    • This topic was modified 4 years, 10 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    CSS would not work very well. You can use JavaScript
    https://www.google.com/search?q=javascript+scroll+to+bottom

    If the page is entirely reloaded, you could include a skip link URL parameter to have the browser scroll to a specific element ID. example.com/messages/#element-id

    Thread Starter jksastrology

    (@jksastrology)

    Hello,

    Thank you so much for your response. The scroller is part of a plugin called “BP Better Messages”

    Unfortunately I am not experienced in modifying php within a wordpress plugin, but trying very hard to learn.

    I have set up a bp-custom.php file, which I use as a child page to modify code. Are you able to point me in the right direction on how I go about changing the way the scroller works. I am not quite sure how to implement the javascript.

    Thank you for your time.

    Jamie

    Moderator bcworkz

    (@bcworkz)

    It sounds like the plugin may not be working as intended. You could try seeking assistance from the plugin developers through their dedicated support channel. I’m unfamiliar with that plugin so I have no advice for altering the plugin workings other than try to work through any available action or filter hooks. Avoid directly altering plugin code if you can.

    If the JS code you want to load is in an external file, use wp_enqueue_script() to get WP to load the file. Call it from the “wp_enqueue_scripts” action.

    If the JS code is fairly minimal, it could be output as inline script inside of <script> blocks. This output could occur almost anywhere, so any action that fires during output could potentially be used. However, you cannot safely place script blocks into the page editor content. It needs to be output with PHP. You can use the “wp_print_scripts” action to output script in the head section. Use “wp_footer” action for script in the footer area.

    Other than how the script gets on the page, JS code works as it does on any web page. Anything you find via search should work for you even if it’s not WP specific.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Set Scroller to Bottom, after pressing a button’ is closed to new replies.