How to remove URL after upload?

Asked

Viewed 2,860 times

1

I have my URL

www.site.com/product/link/code/1

After loading, I would like the URL not to appear in the browser, just www.site.com

How can I do that?

1 answer

8


This Javascript command clears the URL by keeping only the domain:

window.history.pushState("", "", "/");

It will be logged in the browsing history because this is actually what this command is for (we use this feature to include an Ajax request in the browsing history and to allow sharing the URL of a page with altered status via AJAX).

Another way would be: instead of the user getting this page by a link, get by a POST, then the POST response is a new page without redirect (the URL will remain the same).

I don’t know your specific need, so here’s a review: a good web app always gives the user the experience of navigating between pages and through links. Even though the app is a wonderful single page like Gmail or something close to it like Facebook, the user will like to be able to browse the history, save pages to bookmarks and share Urls. If the application uses the feature I described (return page through POST), the user has the experience of impaired use.

  • 1

    In a commercial application, for example, an Erp, I don’t see the need to keep browsing with Urls, besides avoiding errors, for example he passes an Id in Edit that doesn’t exist...etc.That’s why I wanted to remove the url

  • My opinion right Caffé, but I agree with you in your opinion too, cases and cases

  • 1

    I understand. I particularly see benefit even in an ERP. The back button is an important concept in web browsing. By keeping the entire application in the same URL you take this resource from users. You will have to worry about valid Ids and Urls, but after dealing with about 3 pages you see that this does not add much programming effort. You know, I think about the guy in accounting looking into a W-note, how cool it would be to be able to save it on the favourites instead of giving it a half dozen clicks every time you want to get back to it. It would also be nice to share the note by sending a URL by email.

  • Yes, it makes sense yes, I’m having problem with a way to create bonds with a certain entity, I even asked a question about it...to try to solve in N ways, but I can’t imagine and avoid mistakes

Browser other questions tagged

You are not signed in. Login or sign up in order to post.