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