0

It would be great if I could use url search params inside <amp-script>. I am not using amp only due to this restriction, for now. Is it by any chance possible to use url search params inside <amp-script>?

Amp can, already, manipulate url search params. I only need the "last mile" of connecting those url search params to my <amp-script>. Is it possible?

Vladimir Brasil
  • 693
  • 5
  • 8

1 Answers1

0

Is that you want to access location.href, or another property of the location object?

If so, there's an open issue for that. I'd encourage you to comment there and explain your use case. Or, better still, AMP is an open-source project, as is WorkerDOM, which <amp-script> is based on. Suggest this and submit a PR!

Ben Morss
  • 116
  • 1
  • 2
  • 1
    It may be possible to do today in a _very_ hacky way by using the `AMPDOC_URL` URL substitution that is sent in the `src` to an `amp-state` which will then echo back the actual value in the JSON response, and then to read that `amp-state` in `amp-script`! Gross!! But it may work. Not recommended though. – Weston Ruter Oct 22 '20 at 18:38
  • Weston, that's pretty ingenious ;) – Ben Morss Oct 23 '20 at 19:42