The Location.assign()
method causes the window to load and display the document at the URL specified. After the navigation occurs, the user can navigate back to the page that called Location.assign()
by pressing the "back" button.
If the assignment can't happen because of a security violation, a DOMException
of the SECURITY_ERROR
type is thrown. This happens if the origin of the script calling the method is different from the origin of the page originally described by the Location
object, mostly when the script is hosted on a different domain.
If the provided URL is not valid, a DOMException
of the SYNTAX_ERROR
type is thrown.