0

If I add a random string as the URL fragments to a url while it is not pointing to any element on the page, Can I make sure that it does not break up any thing?

For example let's say that I want to open http://example.com with my Firefox browser, if I add a random string to the url as a fragment such as http://example.com#t1234567843 while t1234567843 is not related to any of the page's elements, Can I make sure that the browser can always open the page without error (regardless of the web application or the filetype: XML, html, xhtml, html5, ...)?

Alex
  • 1,914
  • 6
  • 26
  • 47
  • 1
    You can be sure that the browser will try to find the element with `name="t1234567843"` or `id="t1234567843"` in your page. If you are on another page, it will load `http://example.com`, then go back to finding the element. If it doesn't find, it will do absolutely "nothing". (In fact, it will scroll you to the top of the page) – Ismael Miguel Jun 13 '16 at 12:50
  • No, apart from some single-page applications which uses the #hash part for routing – dayuloli Jun 13 '16 at 13:20
  • You mean it does not break up any thing except the cases that the page itself is using #hash to scroll the page. In the later case just scrolling does not work but it does not result in any error.Am I right? – Alex Jun 13 '16 at 13:42

1 Answers1

-1

According to my research and testing, generally, no. An invalid URI Fragment does not 'break the page load'. However, take note of Ismael Miguel's and dayuloli's comments above. I believe both are correct and noteworthy.

See also this question: What is href="#" and why is it used?. It details that the URI Fragment is only interpreted locally by the browser. If it references an nonexistent location within the document, the browser simply loads the document and positions as per usual (top of the page).

ScottWelker
  • 1,701
  • 17
  • 30