1

I'm injecting a Elm feature to an existing page written by PHP.

The data responded from server for an item has url : "this-is-detail-link.html" and I need to get the host name to concat with the url. For example:

case Msg of
    GoToDetailPage item ->
      let
        hostname = getHostNameFromElm // <- how can I get this?

        // expected: http://example.com/this-is-detail-link.html
        fullUrl = 
          Url.Builder.crossOrigin hostname item.url []

        cmd = 
          Browser.Navigation.load fullUrl


      in
      (model, cmd)

I am using Browser.element

main =
    Browser.element
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }

Try to search but not what I expect. It requires to use Browser.application, not a part like this. Any suggestion? Thanks in advance!

bird
  • 1,872
  • 1
  • 15
  • 32

1 Answers1

0

I've seen that you already solved it, but remember that you can always use Javascript through ports.

Here is an example app using ports to get the origin, please not that because Ellie renders inside an iFrame, I couldn't get the hostname directly. You just need to change to window.location.hostname.

https://ellie-app.com/8ggN625V8T6a1

Romario Lopez C
  • 184
  • 1
  • 7