score:6
Accepted answer
You can achieve this by first appending the fragment to the URL, then reloading the page:
window.location.href += '#post-' + data.post_id;
window.location.reload();
Note however that you could improve this further by using pushState and avoiding the need to reload the page at all when the fragment changes.
score:0
Related Query
- How do update and redirect to previous page using javascript
- How can I load javascript when needed into a single page ASP.NET MVC4 web site?
- How can I make a redirect page using just a button and jQuery-Freemarker?
- How can I fix my JavaScript page refresh
- How can I call a new web page from javascript / jQuery
- How to Refresh a page in JavaScript and redirect to controller's Action method with parameters
- How can I validate a multi page form with html 5 javascript required before moving to the next page
- How can we constraint/restrict the user from page reloading or browser back or forward using javascript
- How can I redirect to another page when an iFrame is detected?
- How can I refresh the page after an ajax call but passing parameters as well? I.e. not full refresh
- How can I decrease playback speed of the video using javascript or jquery?
- How can I get client ID and redirect URL when a user login to instagram through my site?
- How can I run previously loaded Javascript using history.pushState
- How can I capture all link clicks after a page is loaded and new links are added?
- How can i put the html element on the page in php using jQuery?
- How can I display form validation messages on the same page as the form itself?
- When clicking on a link inside the accordion menu, how can I keep the accordion menu open once the page is refreshed with new html content?
- How can I pass data read from a JSON file to the rest of my Javascript code?
- How to show files in iframe by Jquery or JavaScript and prevent to show in another page loading?
- How can i call a javascript function from a child window to an iframe where in main window?
- How can I load() or get() a html page and save it in a variable?
- How to load page only after JavaScript function has finished executing and performed its magic?
- How can I autoplay this javascript slider?
- How can I use jQuery or javascript when I write a post in Wordpress
- how to stop double javascript trigger at the bottm of the page
- How can I test this JavaScript effectively?
- How can i dock an asp.net: table to my web page so it (the table dock) dynamically adjusts to browser width?
- how to pass the value one page javascript to another page javascript
- How can I remove a specific css element from a specific page with jquery?
- How can I post a 2D JavaScript array to the server?
- How can I get data from an external web page into CRM 2011?
- How can I have multiple instances of this jQuery image slide effect on one page
- How can I wrap JSON objects in an array using Javascript or Jquery?
- How can i make the page wait before it forward to another page?
- how we can go to page 1 and 2 and 3
- Javascript /jQuery: How can I make this AJAX request run faster?
- How to put a script that calls itself in a page
- How can we fetch values from a jquerymobile page and show it using a prompt box?
- How can i change options in drop down menus if they are generated dynamically using javascript
- How do I preload HTML that is written by a Javascript on page load?
- How can I cut a javascript array in half but to the nearest closing </p> or </h1> tag?
- How can I save a url hash to a variable for use on a different page with a different url?
- Redirect after login , cached page issue - Javascript
- How to redirect page in Windows Phone
- How can I implement Javascript autocomplete functionality?
- How do I reload a page in Javascript only after the new page is fully loaded
- How can I remove part of a string with javascript or jQuery?
- How can i run lightbox jquery in one html page more time
- how can i Hide element of iframe in wordpress page template
- How can i hide the calendar-div inside the jQuery-ui datepicker by JavaScript code?
More Query from same tag
- How to append image and anchor tag
- How do I make my jQuery countdown code work
- How to handle session time out warning with JQuery and ColdFusion?
- Can't Remove Active Class From a Tab Click
- How do I attach FUNCTION to future elements?
- Vertically Center - jQuery
- hover selection to show hidden items
- jquery ajax load function not loading content
- How can I show the duplicate data in Asp.Net MVC 5?
- jQuery: Get middle point of box, place object above on button click
- how to slide my content one by one clicking button(prev/next) or arrow in jquery?
- 2 AJAX forms on same page: prevent open one if the other is already oppened
- if click on any leftside box will append to right side first box only
- I need to fetch html tags given inside textbox using jquery
- How does one utilize JSON response data from an AJAX call?
- I'm attempting to make a placeholder image for my app in react when theres no image available
- Building a selector with literals and variables?
- How do I declare a jquery object using the model in asp.net mvc?
- Closing of dialog also closes datepicker - jsfiddle included
- jquery deferred and css3 transitions
- beforeunload is navigating to previously visited page instead of POST action url on form submit in Javascript
- Dialog position
- Rebind JQuery Validation
- How to save dropdown list selected item value and listbox items value to database using jquery & ajax
- Semantic UI accordion overlap position fixed element
- Drag and drop in Sliders using Webdriver java
- javaScript error : is not a construct
- HTML Form into CSV Files with JS and JQuery
- linear animate into variable width
- json, trying to access array