1 | initial version |
In Elm, you can retrieve the window.location.href
using the Browser.Navigation
module. This module provides a function named getLocation
which returns the current location of the page.
You can use the Browser.Navigation.getLocation
function in your code as follows:
import Browser.Navigation
main =
Browser.Navigation.getLocation (\location ->
-- Do something with the location variable here
)
The getLocation
function takes a callback function as an argument, which will be called with the location object. You can then use the location object to access the various parts of the URL, including the href
property.
For example, you can retrieve the current URL's href
property as follows:
import Browser.Navigation
main =
Browser.Navigation.getLocation (\location ->
let href = location.href
in
-- Do something with the href variable here
)