1

I have this index page with 2 iframes. In one of the iframes in the page I have some links:

<a href="home.html" target="content" onclick="run.slimmscroll(#anchor1);">Home</a>
<a href="home.html" target="content" onclick="run.slimmscroll(#anchor2);">Home</a>
<a href="home.html" target="content" onclick="run.slimmscroll(#anchor3);">Home</a>

The home.html is loaded into the "content" Iframe. Now I need to execute a Jquery script on the home.html when it is loaded. Here is the script:

<SCRIPT type="text/javascript"> 
$(window).load(function() {             
$('#scroll').slimScroll({    
start: $('#anchor1')
  });    
 });
</SCRIPT>

The idea is to get home.html to #anchor1, 2, 3 and so on with smooth scrolling which it normally does on page load but I would like to do it with the onclick() from the other page.

Hope you guys can help.

Stanimirovv
  • 3,064
  • 8
  • 32
  • 56
easy rider
  • 182
  • 2
  • 11
  • Do you have a fiddle showing what you're trying to do? – jameslafferty Jan 08 '14 at 13:49
  • No I don't. Index page is very large. – easy rider Jan 08 '14 at 13:54
  • I've worked with slimscroll a lot but I have no idea what you're trying to do ... try to explain it better. – Joel Blum Jan 08 '14 at 13:56
  • @Joel_Blum, Standard I use #anchor1 in the link and when the home.html is loade into the iframe it goes to #anchor1 but it does not go smooth to #anchor1 so I want to execute the script on the page so it will smooth scroll to #anchor1 from the link. From another link (home.html onclick="run.slimmscroll(#anchor2) I would like to smooth scroll to #anchor2. – easy rider Jan 08 '14 at 14:02
  • To simplify my question: I just need to execute a script on one iframed page from another iframed page with onclick() – easy rider Jan 08 '14 at 14:08
  • Need to do somthing like this but not on the parent page but the iframed page. http://stackoverflow.com/questions/2161388/iframe-function-calling-from-iframe-to-parent-page-javascript-function – easy rider Jan 08 '14 at 14:31

1 Answers1

0

Got it.

onclick="window.parent.content.slimScroll();"

The syntax on the home.html would be:

<SCRIPT type="text/javascript">              
$('#scroll').slimScroll({    
start: $('#anchor1')   
});
</SCRIPT>
easy rider
  • 182
  • 2
  • 11