0

I have a page with a URL like below:

http://mysite/link_to_somepage#label

I'm using fullpage.js to have multiple sections in my page which uses anchors to point to each individual section. The last part of the url is a label for anchoring to multiple sections in the page. It can get several values based on status of page. The problem is user might get to some section(which changes the section label in the URL) and then if he/she reload the page it will go to that particular section based on the last label specified in the URL and this is something that i need to change. I need to change the label section of the URL before finishing the load of the page to some default label, or just remove the whole label part to prevent fullpage to scroll to that section(I want to always go to the first section on page load).

I'm using jquery and I have no idea how to do this. Any Suggestion is highly appreciated.

Firouziam
  • 777
  • 1
  • 9
  • 31
  • Javascript will not run until the page is loaded. You can execute some javascript before the entire page is parsed into the dom, but at that point, the browser has already gotten the page contents. – Taplar Jan 16 '19 at 17:51
  • Thanks for the comment. It's satisfactory to change the URL in document onready. Because the wrong section label messes some js that runs after the page is loaded and there is nothing wrong with the loaded content. I will edit the question to make it more clear. – Firouziam Jan 16 '19 at 18:00
  • 1
    https://stackoverflow.com/questions/37447778/remove-hash-in-url-fullpage-js Take a look here – Onkar Jan 16 '19 at 19:07
  • Hey Firouz - just following up. Was your question answered satisfactorily? If there is more we can help with, please add a comment below my answer, or edit your question to ask for more help. Otherwise, it would be great if you could upvote and/or choose a "best answer" - *as you know, it costs you nothing but helps the other guy.* If no answer was helpful, please post your own answer and select it with the checkmark to let me know how you solved it. *Thanks M8!* – cssyphus Mar 10 '19 at 15:18

1 Answers1

0

If you use javascript/jQuery to change the url, the page could refresh(*). What might do the trick for you is to look into the .htaccess file (assuming you are using a LAMP stack).

(*) New information - see this:

How to modify the URL without reloading the page?


Using javascript to parse/change the url:

How do I parse a URL into hostname and path in javascript?


Getting started using .htaccess file to modify the url:

https://www.noupe.com/development/htaccess-techniques.html

https://perishablepress.com/stupid-htaccess-tricks


If using a Microsoft stack, see this:

.htaccess or .htpasswd equivalent on IIS?

cssyphus
  • 37,875
  • 18
  • 96
  • 111