How to include ALL parameters in the URL captured in Javascript, to add full URL to a pre-populated email

I can successfully pre-populate an email from a button click with the first part of the page URL, and the first parameter in the URL, but it’s cutting off after that. I have multiple parameters in the URL. How do I capture them all and put the full URL in the link in the email?

So for the url e.g. https://website.com/folder?param1=one&param2=two

Current code:

<div class="button">
  <a href="mailto:?subject=Email title&body=Here’s a link: &nbsp; [sub]" data-message="" 

onclick=”this.href = this.href.replace(‘[sub]’,window.location)”>Email me a link to this page

This is populating the email link part with https://website.com/folder?param1=one only. &param2=two is missing.

I’ve also tried with

<div class="button">
  <a href="mailto:?subject=Email title&body=Here’s a link: &nbsp;" data-message="" 

onclick=”this.href += window.location.href;”>Email me a link to this page

Which has the same result.

I have a feeling it’s to do with needing to use URLSearchParams and specify the parameter names, but I don’t know how to write this into the existing code. I read MDN but I’m a beginner so need help.

Thanks in advance.