Ever came across a requirement where you need to grab the current page URL from JavaScript. See below examples to learn how to achieve this and some other parts of URL with the help of window.location object. You can either use the code directly or save it in a variable and then use.
Code Type : Get entire Location (URL)var url = window.location.href;
Code Type : Get Location HostName
var hostName = window.location.hostname;
More Posts related to JavaScript,
- Add Animated Scrolling to Html Page Title Script
- How to get query string in JavaScript HTML location.search
- How to get current URL Location using Javascript HTML
- How to detect Browser and Operating System Name and Version using JavaScript
- Submit html form on dropdown menu value selection or change using javascript
- How to Print from JavaScript HTML using window.print
- JavaScript : Get url protocol HTTP, HTTPS, FILE or FTP
- JavaScript : Get current page address
- How to send email from JavaScript HTML using mailto
- Send Extra Data with Ajax Get or Post Request
- Write javaScript code in Swedish using FikaScript
- Get Device Screen Width and Height using javaScript
- How to get UTC (GMT) using javascript
- Javascript convert text case from uppercase to lowercase
- Loading previous page using html button using JavaScript
- [javaScript] Convert text case to lowercase
- Detect if Cookies are enabled using JavaScript
More Posts:
- This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) Lint Error - Android
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files - Java
- Your Android SDK is out of date or is missing templates. Please ensure you are using SDK version 22 or later. - Android
- How to repeat tile background image in Android Activity - Android
- How to change Android Button Color using xml attribute and programatically using java - Android
- Maven : java.lang.ClassNotFoundException: Xmx512m - Android
- How to Get or Set SharePoint Document ID _dlc_DocId using PowerShell - SharePoint
- How to find AUTO_INCREMENT fileds value in mysql table - MySQL
- Add Animated Scrolling to Html Page Title Script - JavaScript
- JavaScript : Get url protocol HTTP, HTTPS, FILE or FTP - JavaScript
- Unable to connect to the Internet : Google Chrome - Chrome
- java.io.IOException: Unable to locate resource handler.properties - Java
- Redirect page using jQuery - jQuery
- Android Studio : Build Tools 23.0.0 rc1 is deprecated - Android-Studio
- Eclipse : This version of the rendering library is more recent than your version of ADT plug-in. Please update ADT plug-in - Eclipse