K
K
Kerm2019-12-13 14:11:19
css
Kerm, 2019-12-13 14:11:19

How to prevent the browser from scrolling the page to the place from which it went to another page when returning to the previous page?

I have Ajax loading of goods on my site, I need that when I go to the product card and return from it back, the browser does not try to scroll the page to the place where the transition was made (anyway, because of Ajax loading of goods, nothing will work) is it possible how do i stop the browser from doing this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Somewhere Intech, 2019-01-23
@john36allTa

element.style.backgroundColor returns result as 'rgb(red,green,blue)'
Must be converted to hex first

function rgb2hex(rgb) {
    rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
    function hex(x) {
        return ("0" + parseInt(x).toString(16)).slice(-2);
    }
    return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}

color = color.indexOf("rgb") !== -1 ? rgb2hex(color) : color;

And set color options in lower case "#0acf00"

E
Enj0y, 2019-12-13
@Enj0y

There is no specific prohibition, but you can tell him where to scroll, for example

$( document ).ready(function() {
    $('html').animate({ scrollTop: 0 }, 'fast');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question