How to reload a page without its parameters?
Use the location object
// similar behavior as an HTTP redirect
window.location.replace(location.protocol + '//' + location.host + location.pathname);
// similar behavior as clicking on a link
window.location.href = location.protocol + '//' + location.host + location.pathname;
angular how to refresh the page without losing the query string they pass to me
Instead of doing window.location.reload
(which I'd argue is an anti-pattern to angular), you can do this within the router and preserve the query string with Navigation Extras
this.router.navigate(['/'], queryParamsHandling: "preserve"});
Can a plain HTML link (A) reload a page without query string values
I think I know a trick. When you use a <form>
tag with empty action
and no (or GET) method
parameter it will use your url but will replace the GET parameters (query string) with the values in your form, so:
On page http://example.com/foo.html?query=string
<form action="">
<input type="submit" value="hello" />
</form>
If you click on the button you will get to:
http://example.com/foo.html
(Firefox 8)http://example.com/foo.html
(Internet Explorer 9)http://example.com/foo.html?
(Chrome 15)http://example.com/foo.html?
(Safari 5)
Edit: the trailing question mark is likely a Webkit issue.
How to reload page without _layout query string parameter
You can use regular expression and remove all instance of _layout
location.href=location.href.replace(/&?_layout=([^&]$|[^&]*)/i, "");
Related Topics
Hierarchical Json from Flat With Parent Id
Javascript Regex - No White Space At Beginning + Allow Space in the Middle
Hiding the Address Bar of a Browser (Popup)
How to Check a Radio Button in the Table Row Based on That Column Header
Display Current Date in Dd/Mm/Yyyy Format
Is It Any Limit for Post Data Size in Ajax
Split a String Only the At the First N Occurrences of a Delimiter
How to Add a New Object (Key-Value Pair) to an Array in JavaScript
How to Read a Properties File in JavaScript from Project Directory
Ngx-Datatable Set Column Width Dynamically
How to Open a Url Link from JavaScript Inside a Google Apps Script HTML Google Site Gadget
Select Li Element With Arrow Keys (Up and Down) Using JavaScript (Jquery)
Passing Variable from One Js to Another Js File in Nodejs
How to Use If Statement Inside Json
Draw a Connecting Line Between Two Elements
How to Move Focus on Next Field When Enter Is Pressed