html – Adding a mailto link that grabs the URL of the current page

I’m trying to add a “submit feedback” link to a SharePoint Modern page that sends an email to a specified support address. One of the requirements is that the mail it pulls up must autopopulate its subject line with the URL of the current page, so that the site owner knows which page the user was looking at when they submitted the feedback.

I haven’t found a good way to do this using built-in SharePoint functionality, so my current attempt is:

  • Create a custom .aspx file with a line of HTML as follows:
  • <a href="mailto:?subject=(sub)" onclick="this.href =this.href.replace('(sub)',document.URL)">Submit Feedback</a>
  • Upload the .aspx file to a document library on the site
  • Use the Embed web part to show the link from the uploaded .aspx file on the page

However, this currently isn’t working the way I want. Instead of showing the URL of the page, the email is pre-populating with the URL of the .aspx file, presumably because it can’t “see” outside of its Embed frame.

How can I achieve my goal here?

  • Is there a better way of implementing my current approach, a different piece of HTML that I could embed that would work?
  • If not, is there a different approach that would achieve my overall goal (mailto link with the current URL prepopulated in the subject line)?