CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   A link on click call and animate div of another page using jquery (http://www.codingforums.com/showthread.php?t=287299)

prachippp 02-08-2013 07:30 AM

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.

niralsoni 02-08-2013 11:12 AM

Code:

$('#home').click(function() {
  $('html, body').animate({
    scrollTop: $(top.frames['f1'].document.getElementById('one')).offset().top
  },2000);       
});


prachippp 02-09-2013 07:02 AM

i have added the code. but it's not working.

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

prachippp 02-09-2013 07:43 AM

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?


All times are GMT +1. The time now is 12:55 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.