How does the URL change without refreshing the page? [duplicate] - javascript

This question already has answers here:
Change the URL in the browser without loading the new page using JavaScript
(14 answers)
Closed 8 years ago.
The URL on this page seems to change when I click in the comments section where it says "x More...".
How this this URL trickery happen?

It is part of the HTML5 history api.

Related

How to prevent the user from leaving my page [duplicate]

This question already has answers here:
Prevent a webpage from navigating away using JavaScript
(10 answers)
Prevent user to leave my page in javascript
(2 answers)
Closed 4 years ago.
I'm trying to make an online test using spring-mvc and html, css, jquery and I want to prevent the user that is doing the test from leave the test screen while doing the test. Does anybody know how I can do that?

how to open external url in new tab in laravel [duplicate]

This question already has answers here:
How to open link in a new tab in HTML?
(12 answers)
Closed 5 years ago.
I opened the external URL using javascript. But it opens in the same window I need to open it in new tab
onclick="window.location= '$url';
You can do it by using only html if you want :
some text
But by javascript this should work :
onclick="window.open('http://my.link.com', '_blank')"

javascript how to direct browser's "back" button to a different web address? [duplicate]

This question already has answers here:
Back button redirect script
(2 answers)
Closed 6 years ago.
I would like to direct the visitor to a different link, once he clicks the "back" button on his browser. I know that it can be done :)
I tried to play with the history of the browser but it didn't work
Thanks!
Elad
Im not sure if this will work since i have never tried this..but here you go:
window.addEventListener('popstate',function() {
window.location.href="www.example.com"/*url you want";
}
You can refer this for further information
https://developer.mozilla.org/en-US/docs/Web/API/Window/history

Automatiaclly crop website before printing the page [duplicate]

This question already has answers here:
remove url and print text from the printed page
(4 answers)
Closed 7 years ago.
I have a HTML file that triggers print() when you click a button. How do you crop the page so the site name and url does not show up?
You cant, including URL and/or title is up to the browsers print dialog.

How to change a URL (not using fragments) in the address bar without redirecting to a page? [duplicate]

This question already has answers here:
How do I modify the URL without reloading the page?
(20 answers)
Closed 9 years ago.
As far as I know it's not possible to change a URL in the address bar without redirecting a page (only updating fragments will work), but in Pinterest.com it seems like only a modal dialog is opened when clicking on a post, and at the same time the URL is updated to ".../post/12356789". I'm curious how do they achieve that?
Thanks!
It's probably done using the history.pushState() method in "HTML5", which lets you manipulate the browser history (to some extent). Here's an article detailing how it works.

Categories

Resources