Javascript Redirect to current page another controller
This example demonstrates a JavaScript function that redirects the browser to a new URL, specifically for impersonating a user account. The function, `impersonate(id)`, first shows a confirmation dialog and, upon user approval, constructs a URL path like `Account/PresentationImpersonateTo/` followed by the given ID, then sets `window.location.href` to perform the navigation. It uses the native browser APIs `confirm()` and `window.location.href`, with no external libraries or frameworks. The code is a straightforward client-side controller action, triggered by user interaction, and relies on the current page’s origin for the redirect target.