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,520 points
5,505 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,840 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,840 points
9,855 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,840 points
990 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,840 points
12,902 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,840 points
875 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,840 points
2,827 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,840 points
4,034 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,840 points
12,036 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,840 points
23,012 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,840 points
6,704 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,840 points
1,481 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