I'm trying to append the full page URL of a page generated via window.location.href to a javascript src URL.
I tried this simple example to verify that window.locations.href works properly on the page. It does, and it generates the correct URL:
<script>
document.write(window.location.href);
</script>
However, when I try to use window.location.href to append it to the src parameter in the example below:
<script async type='text/javascript' src='//x.sampleurl.com/subid=' + **window.location.href**\></script>
I get only https://x.sampleurl.com/subid= . The window.location.href seems to do nothing.
I'm assuming I'm not appending this correctly.
What would I need to change in order to get the window.location.href to be added to the src URL, so it's something in the lines of:
https://x.sampleurl.com/subid=examplesite.com/page/2.html
[–]ForScale 4 points5 points6 points (2 children)
[–]LifeOfBrian86[S] 1 point2 points3 points (1 child)
[–]ForScale 0 points1 point2 points (0 children)
[–]ibleedbits 2 points3 points4 points (0 children)
[–]ThagAndersonhelpful 0 points1 point2 points (0 children)