From the comment: HTML is idle. As soon as you change href, none of the following is taken into account when downloading the code. You need to pass something to the receive page (for example, the query string parameter on prew2.html ) and respond to it instead inside prew2.html .
The receiving page should know whether to scroll or not show the desired location. This decision, whether or not to scroll, is made by the caller.
The obvious method is to pass the parameter in the query string. Since this code acts just like the bookmark URL, you can also use the bookmark URL for the task and check the specific value of the bookmark:
On the first page, the link code will look something like this:
$("#audio2").click(function(){ window.location.href = "prew2.html#doitnow"; });
Of course, if it is a regular anchor, it will do the same:
<a id="audio2" href="prew2.html#doitnow">Click me</a>
On the reception page, the code will look like this:
$(function(){ // Shortcut for DOM ready handler if (location.href.indexOf("#doitnow") >=0 ){ $('.parallax').animate({ scrollTop: windowHeight*2.6 }, 'slow'); } });
source share