Show anchor in URL

Hello,

I’m working on a one-page site (http://djebots.tic.heia-fr.ch), I create some anchors with the menu to scroll automatically down in the page but I can’t see the anchor in the URL.

I also want that the URL change with the anchor when I scroll down the page and I’m in a specific section, is that possible? (example https://messenger.fb.com/get-started)

Regards,

Simone

Hello Simone,

I don’t think that there is an easy way to do it, unfortunately.

Please feel free to ask any other questions that you might have.

Kind Regards, Roman.

Hello, i find a solution, i wrote some lines with jQuery:

/*==== Add span for menu landing ====*/
jQuery(document).ready(function($){

var anchorText = ["pourqui", "casusage", "apropos", "expertise", "platforme", "contact"];

	for(var i=0; i<6; i++){
		   	var html = "<span href='#"+anchorText[i]+"' class='anchor-menu' id='"+anchorText[i]+"'></span>";
    $('#pg-17-'+i+'').prepend(html);
	}

});


/*==== Show anchor in URL ====*/

jQuery(function () {
    var currentHash = "entry";
    jQuery(document).scroll(function () {
        jQuery('.anchor-menu').each(function () {
            var top = window.pageYOffset;
            var distance = top - jQuery(this).offset().top;
            var hash = jQuery(this).attr('href');

            if (distance < 150 && distance > -150 && currentHash != hash) {
                window.history.pushState("state", "page 1", hash);
                currentHash = hash;

            }

            var height = jQuery(window).scrollTop();
            if (height == 0){ window.history.pushState("state", "page 1", " "); currentHash = "entry" }
        });
    });
});

Regards,

Simone.

Great, and thanks for sharing it!

Kind Regards, Roman.