I want to insert the name of the currently accessed webpage into a specific location in a div
parameter value.
For example in the code below, I want to insert the page name (pathname) where you see current_page_pathname
.
<div data-url="https://somedomain.com?source=current_page_pathname"></div>
I've looked at using var current_page_pathname=window.location.pathname;
, but I don't know how to insert the var
value where I want it.
If the currently accessed webpage is https://en.wikipedia.org/wiki/Sloth
, I want the data-url
value to be:
<div data-url="https://somedomain.com?source=/wiki/Sloth"></div>
Is this possible?
Am I going about this the wrong way? I'm open to any solution that works.