I am using a scroll function, and recently added a refresh with it
(cause I had a mail form and this was the easiest way to get the
?resp=0/
thing away. Yes I know there were other ways but this one was the best one to use for me, so please don't suggest other ways to do that process)
somehow sometimes when I refresh the page, it doesn't notice on what position it is. I have things starting on display:none
but when it is on a certain place on the page it is display:block
. When I scroll the page suddenly updates (like images appearing cause they get display:block
, and the url changing from index.php#this
to index.php#that
). I would like it if it changed instantly on refresh so it doesn't need the scrolling first.
Most of the times it works fine but just sometimes it will act like that, I don't know were the problem is.
code below:
$(function () {
$(window).bind('scroll', function () {
if ($(window).scrollTop() > ($(document).height() / 4.65) * 3) {
$('.Attribute').removeClass('that').addClass('this'); (etc..)
if (performance.navigation.type == 1) {
window.location.replace("index.php#this");
}
}
else if ($(window).scrollTop() > ($(document).height() / 4.65) * 1.3) {
$('.Attribute').removeClass('that').addClass('this'); (etc..)
if (performance.navigation.type == 1) {
window.location.replace("index.php#that");
}
}
else if ($(window).scrollTop() > $(document).height() / 4.65 * 0.3) {
$('.Attribute').removeClass('that').addClass('this'); (etc..)
if (performance.navigation.type == 1) {
window.location.replace("index.php#things");
}
}
else if ($(window).scrollTop() < $(document).height() / 4.65 * 0.3){
$('.Attribute').removeClass('that').addClass('this'); (etc..)
if (performance.navigation.type == 1) {
window.location.replace("index.php#something");
}
}
});
});