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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts

    A link on click call and animate div of another page using jquery

    hello,
    i have link in one page and on click on link i want to animate div which is inside another page.

    i am using following code but it is not working.

    $('#home').click(function() {

    $('html, body').animate({

    scrollTop: $("#f1 #one").offset().top
    },2000);
    });

    another page is called in iframe.

    #f1 is the iframe's id and #one is div's id.

    i want if anyone click on home link #one should be animated and scroll to top using jquery.

    please reply me soon.

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Location
    London
    Posts
    152
    Thanks
    4
    Thanked 42 Times in 42 Posts
    Code:
    $('#home').click(function() {
      $('html, body').animate({
        scrollTop: $(top.frames['f1'].document.getElementById('one')).offset().top
      },2000);	
    });

  • #3
    New Coder
    Join Date
    Jun 2011
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts
    i have added the code. but it's not working.

    let me know if there is any other way for that.

  • #4
    New Coder
    Join Date
    Jun 2011
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts
    i have searched on google and written following code in another page which is inside iframe :

    $(parent.document,'#home').click(function() {
    $('html, body').animate({

    scrollTop: $("#one").offset().top
    }, 2000);
    });

    $(parent.document,'#compn').click(function() {
    $('html, body').animate({

    scrollTop: $("#four").offset().top
    }, 2000);
    });

    $(parent.document,'#srv').click(function() {
    $('html, body').animate({

    scrollTop: $("#two").offset().top
    }, 2000);
    });


    now it is animating, but still not animating properly.

    it animates whole page twice and then stuck on one position only.

    can anyone help me for that?


  •  

    Posting Permissions

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