Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8071727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:46:57+00:00 2026-06-05T13:46:57+00:00

using chrome and ff so far have made a nasty glitch when using scrollTo

  • 0

using chrome and ff so far have made a nasty glitch when using scrollTo function? anyone know how to prevent this from happening?
Live Code

HTML

 <ul class="wrapper">
    <li class="listItem"><img src="asset/img/logo.png" ></li>
    <li class="listItem"><a onclick="scrollTo('#container',500);" href="#">Company</a><span> / </span></li>
    <li class="listItem"><a onclick="scrollTo('.flexslider-container',500);" href="#">Service</a><span> / </span></li>
    <li class="listItem"><a onclick="scrollTo('#map',500);" href="#">Map</a><span> / </span></li>
    <li class="listItem"><a onclick="scrollTo('#footer',500);" href="#">Contact</a></li>
    <li class="listItem">
      <p>250-610-9100</p>
    </li>
  </ul>

SCRIPT

<script type="text/javascript">
function scrollTo(o, s) {
    var d = $(o).offset().top;
    $("html:not(:animated),body:not(:animated)").animate({
        scrollTop: d
    }, s);
}
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:47:00+00:00Added an answer on June 5, 2026 at 1:47 pm

    You should be attaching events via .on(), not shoving code into the onclick attribute.

    The (more) proper solution is to give you links a class:

    <a href="..." class="menu-link">...</a>
    

    And then some fancy data attributes:

    <a href="..." class="menu-link" data-target="#container" data-duration="500">...</a>
    

    And in your code, add this:

    $(document).ready(function() {
      $('.menu-link').on('click', function(event) {
        event.preventDefault();  // <---- This is the magic stuff
    
        scrollTo($(this).data('target'), $(this).data('duration'));
      });
    });
    

    Basically, you give your elements special attributes that can be read with jQuery’s .data() function. Then, instead of adding a function call to each link, you attach one magic function to all of them.


    If you want to keep your current code (ehh), just add return false; at the end of every onclick attribute:

    <a onclick="scrollTo('.flexslider-container',300);return false;" href="#">Service</a>
    

    This prevents the default action from occurring (scrolling to the top of the page).

    I recommend my first solution. You aren’t doing jQuery any justice if you are only using it to a third of its potential.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
Problem I have a custom tab control using Chrome-shaped tabs that binds to a
I know Firebug is the standard, but I find myself using Chrome a lot
I have a feeling that this probably is not possible using strictly CSS, but,
I have a very weird problem. This ONLY affects Firefox on Mac, using the
I have a Google Chrome extension that opens a Twitter Bootstrap dialog (using JQuery
I'm using chrome devtools network API and the following code but always the alert
I want to notify an user using Chrome browser. I need something powerful like
Site in question: http://www.sedulity.tk/ Site using Chrome 19 dev: Site using IE9: as you
I can't figure out what is going on. I'm using Chrome to debug my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.