Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-08-2013, 07:30 AM   PM User | #1
prachippp
New Coder

 
Join Date: Jun 2011
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
prachippp is an unknown quantity at this point
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.
prachippp is offline   Reply With Quote
Old 02-08-2013, 11:12 AM   PM User | #2
niralsoni
Regular Coder

 
Join Date: Mar 2008
Location: London
Posts: 129
Thanks: 1
Thanked 31 Times in 31 Posts
niralsoni is an unknown quantity at this point
Code:
$('#home').click(function() {
  $('html, body').animate({
    scrollTop: $(top.frames['f1'].document.getElementById('one')).offset().top
  },2000);	
});
niralsoni is offline   Reply With Quote
Old 02-09-2013, 07:02 AM   PM User | #3
prachippp
New Coder

 
Join Date: Jun 2011
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
prachippp is an unknown quantity at this point
i have added the code. but it's not working.

let me know if there is any other way for that.
prachippp is offline   Reply With Quote
Old 02-09-2013, 07:43 AM   PM User | #4
prachippp
New Coder

 
Join Date: Jun 2011
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
prachippp is an unknown quantity at this point
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?
prachippp is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:59 PM.


Advertisement
Log in to turn off these ads.