Open URL in the Same Window and Tab
Opening a URL in a new tab can often disrupt user experience. To open a link in the same window and tab that contains the page with the link, use the window.open function with the _self parameter.
For example:
window.open("https://example.com", "_self")
This line of code will open the URL "https://example.com" in the same window and tab where the original page is displayed.
Note that starting with HTML5, the window.open function requires an absolute URL (prepended with a protocol). Without it, window.open will try to open the URL relative to the current page, which may not be the desired behavior.
The above is the detailed content of How to Open a URL in the Same Window and Tab in HTML5?. For more information, please follow other related articles on the PHP Chinese website!