
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML Location assign( ) Method
The HTML Location assign() method loads a new HTML document without replacing the URL of the current HTML document from the document history.
Syntax
Following is the syntax −
location.assign(URL)
Let us see an example of HTML Location assign() Method−
Example
<!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat; text-align: center; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 20px; width: 330px; display: block; color: #fff; outline: none; cursor: pointer; margin: 1rem auto; } </style> <body> <h1>HTML Location assign() Method Demo</h1> <button class="btn" onclick="display()">Load Tutorialspoint</button> <script> function display() { location.assign("https://tutorialspoint.com/"); } </script> </body> </html>
Output
Click on “Load Tutorialspoint” button to load tutorialspoint document in the current document−
- Related Articles
- HTML DOM Location reload() method
- HTML DOM Location replace() method
- HTML DOM KeyboardEvent location Property
- HTML DOM Location hash Property
- HTML DOM Location host Property
- HTML DOM Location hostname Property
- HTML DOM Location href Property
- HTML DOM Location origin Property
- HTML DOM Location pathname Property
- HTML DOM Location port Property
- HTML DOM Location protocol Property
- HTML DOM Location search Property
- HTML Window moveBy() Method
- HTML Window moveTo() Method
- HTML Window resizeBy() Method

Advertisements