Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile Show element scrolls the page to the top: Solved

    This problem solved

    Okay I have another question.

    In my code, using the "ajax" call I load an html div into my page, define its top and left and then make it visible using ".fadeIn()" (".show()" does the same thing). The element is positioned fixed and I want it (no matter where I am scrolled on the page) to show up the distance from the top and left that I specify. Instead it scrolls me to the top of the page before showing the element. How can I stop this scrolling and have it just show where I am scrolled on the page?

    Code:
    //".floating_box" refers to the div in the html
    $.post(html_url, function(data){
    	$('body:last-child').append(data);
    	add_functionality();
    });
    $('.floating_box').css({'top' : '40px', 'left' : '400px'});
    $('.floating_box').fadeIn('fast');
    Last edited by mberkom; 03-31-2009 at 07:22 PM. Reason: problem solved

  • #2
    Regular Coder
    Join Date
    Feb 2009
    Location
    Wheeling, IL
    Posts
    358
    Thanks
    5
    Thanked 62 Times in 60 Posts
    Doesn't seem to achieve that effect when tested locally. Where is the rest of your code? Perhaps something else is doing it... like a refresh or something else along those lines?
    The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

    How to ask smart questions?

  • #3
    New Coder
    Join Date
    May 2008
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Alright, here is all my code. Problem occurs at line #103 in the scripts.js file. Thanks for the help.

    Code removed
    Last edited by mberkom; 03-31-2009 at 07:23 PM.

  • #4
    Regular Coder
    Join Date
    Feb 2009
    Location
    Wheeling, IL
    Posts
    358
    Thanks
    5
    Thanked 62 Times in 60 Posts
    And the jumpy effect comes from:

    Code:
    <a href="#" class="activate_link">Activate Box Load</a><br />
    I would suggest doing the following instead:

    Code:
    <a href="#" onclick='return false;' class="activate_link">Activate Box Load</a><br />
    Which should force the browser to NOT follow the link and thus jump all the way up to the start of the page.
    The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

    How to ask smart questions?

  • Users who have thanked Eldarrion for this post:

    mberkom (03-31-2009)

  • #5
    New Coder
    Join Date
    May 2008
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That was easy! I should have thought that it was the link reloading the page. Thanks for the help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •