I have been trying to use the window.location.search inside my custom javascript to get the page URL in AMP page but I am getting empty field. Is there any way/function by which I can get the page URL?
Asked
Active
Viewed 252 times
1 Answers
0
To maintain AMP's performance guarantees, custom JS code runs in a Web Worker, and certain restrictions apply. So you can't act on elements that are outside of the <amp-script>
component (Web Worker). In other words, it's virtual DOM. Documentation for <amp-script>
component.
Here is a very similar question. Also check these comment posted by @Weston Ruter, that might be a solution for your problem.
Alternatively you can try using PHP instead.

la_petite_kozel
- 826
- 5
- 26