How do I modify the URL without reloading the page

0 votes

I would like to access the portion before the # hash if possible.

I only need to change the portion after the domain, so it's not like I'm violating cross-domain policies.

 window.location.href = "www.mysite.com/page2.php";  // Sadly this reloads

Is there a way I can modify the URL of the current page without reloading the page?

Jun 20, 2020 in Java-Script by kartik
• 37,510 points
5,064 views

1 answer to this question.

0 votes

Hii @kartik,

HTML5 introduced the history.pushState() and history.replaceState() methods, which allow you to add and modify history entries, respectively.

window.history.pushState('page2', 'Title', '/page2.php');

Hope this is helpful!!

answered Jun 20, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

How to change url after success in ajax without page reload?

Hello @kartik, Use the browser history to change ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
9,355 views
0 votes
1 answer

How do I return the response from an asynchronous call?

Hello @kartik, You are using Ajax incorrectly. The ...READ MORE

answered Jun 17, 2020 in Java-Script by Niroj
• 82,880 points
733 views
0 votes
1 answer

How do I POST urlencoded form data with $http without jQuery?

Hello @kartik,  I think you need to do ...READ MORE

answered Jul 27, 2020 in Java-Script by Niroj
• 82,880 points
11,909 views
0 votes
1 answer

How do I copy to the clipboard in JavaScript?

Hello @kartik, To copy HTML , you can ...READ MORE

answered Aug 28, 2020 in Java-Script by Niroj
• 82,880 points
699 views
0 votes
1 answer

How do I post a form in laravel 5 using ajax?

Hello @kartik, You can solve this error by ...READ MORE

answered Jun 11, 2020 in Java-Script by Niroj
• 82,880 points
2,470 views
0 votes
1 answer

Error:Sending Form file with form using AJAX

Hello @kartik, Don't pass the files into the ...READ MORE

answered Jun 16, 2020 in PHP by Niroj
• 82,880 points
3,454 views
0 votes
1 answer

How to return AJAX response Text?

Hello @kartik, What you need to do is ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
11,100 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
21,918 views
0 votes
1 answer

How can I change the page URL without refreshing the page?

Hello @kartik, This is simple you just need change ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
6,294 views
0 votes
1 answer

How can we change the page URL without refreshing the page?

Hello @kartik,  In HTML5 you can change the ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
1,114 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP