0

This is my website: http://www.ragewarsclan.com

I was having trouble integrating a Forum into my website. I used object at first then realised that this wouldn't be the best solution, so I switched to iframe and used this code:

    <div style="margin: 0 auto; width:100%; height:100%;
overflow: auto;"><iframe src="./smf/" width="100%" height="100%"></iframe></div>

This only seemed to work for chrome as in other browsers the height of the forum would only be something like 250px so I changed from having 100% to 1750px. However, now, when the user clicks on one of the forum categories, it puts the user near the bottom of the page so I used jquery and used this to try and force the user to the top of the page when a forum category has been clicked:

<script type="text/javascript" src="jQuery-1.4.1-min.js">

$(document).ready(function(){
    $(this).scrollTop(0);
});

</script>

Although this hasn't seemed to have worked and I'm not sure why...

Thanks.

  • http://stackoverflow.com/questions/4210798/how-to-scroll-to-top-of-page-with-javascript-jquery have a look? – Dmitry Sadakov Jan 17 '14 at 21:48
  • That's a letter o, not a zero. – Blazemonger Jan 17 '14 at 21:48
  • if the page is not in an iframe it works perfectly: ragewarsclan.com/smf, but in the iframe the links don't work: http://www.ragewarsclan.com/Forum.html, so the real problem is with the non-working links – bugovicsb Jan 17 '14 at 22:04

2 Answers2

0

you can make your forum categories links and set their href to an element at the top of the page

http://jsfiddle.net/sTr8F/

<div id="top"> top of page. scroll down to find link and click on it </div>

<a href="#top"> forum category </a>
CodeToad
  • 4,656
  • 6
  • 41
  • 53
0

scrollTop doesn't scroll to the top, it returns the y-offset of the page.

If you need to scroll the page to the top using jQuery (so you can do it also smoothly) you can use animate

$("html, body").animate({scrollTop:0},500);   //will be done in 500ms
Alvise Susmel
  • 569
  • 4
  • 9