Well, first I'd try a few out manually to make sure it does the trick and to determine which code you want to use. I think that:
top.window.scrollTo(0,0)
will work in most situations. The only problem with that would be if there is another page on top of everything else including the page with the iframe on it.
Once you've determined which code you like, you can make up a script to assign it to all links on a page:
Code:
(function(){
function add_to_links(){
function added_click(){
top.window.scrollTo(0,0);
return true;
}
var l=document.getElementsByTagName('a');
for (var i = 0; i < l.length; i++)
if ( typeof window.addEventListener != "undefined" )
l[i].addEventListener( "click", added_click, false );
else if ( typeof window.attachEvent != "undefined" )
l[i].attachEvent( "onclick", added_click );
}
if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", add_to_links, false );
else if ( typeof window.attachEvent != "undefined" )
window.attachEvent( "onload", add_to_links );
})();
Save that to a file called add_links.js and put it in the root of your domain. Then on all pages where you want this done put this in the head:
HTML Code:
<script src="/add_links.js" type="text/javascript"></script>
That will do it for virtually all modern browsers with javascript enabled.
Bookmarks