This sounds very specific, but it likely occurs any time someone is using a fixed element as a page header and wants to use # in the url to direct users to particular element in the html.
I'm trying the following. It displays the alert (used for bug checking) but doesn't scroll:
window.onload = function onload()
{
if(window.location.hash)
{
alert("test");
window.scrollBy(0, -300); // The height of my header is 300px
}
}
Is this an okay approach an I'm just missing something? Is there some bug about trying to scroll on page load? Is the scroll somehow overwritten by the # direction. Is there just a syntax error? is there a better approach to solving this altogether?