1

I am using given below code to copy url, but i am thinking about something different like in given example -- https://oauth2.example.com/code?state=state_parameter_passthrough_value&code=4/0AdQt8qg5KBjhjcHixOZMVfpO4cl_UB8NpoV9-GxBzeiI8xCH_8oqzmYhXvGrAx1SyEFYyQ&scope=https://www.googleapis.com/auth/drive.metadata.readonly

This is the complete url. But i wanted to only copy in clipboard THis ---

4/0AdQt8qg5KBjhjcHixOZMVfpO4cl_UB8NpoV9-GxBzeiI8xCH_8oqzmYhXvGrAx1SyEFYyQ

If this is possible, please somebody guide me.

here the html

 <div class="container">
        <div class="label">
            E-mail address
        </div>
        <div class="copy-text">
            <input type="text" class="text" value="david@stylus.co.za" />
            <button><i class="fa fa-clone"></i></button>
        </div>
    </div>

here the java script:

let copyText = document.querySelector(".copy-text");
copyText.querySelector("button").addEventListener("click", function () {
    let input = copyText.querySelector("input.text");
    input.select();
    document.execCommand("copy");
    copyText.classList.add("active");
    window.getSelection().removeAllRanges();
    setTimeout(function () {
        copyText.classList.remove("active");
    }, 2500);
});
Ankit
  • 123
  • 9

1 Answers1

1

Use this code for your Substring

const params = new Proxy(new URLSearchParams(window.location.search), {
      get: (searchParams, prop) => searchParams.get(prop),
    });
    // Get the value of "some_key" in eg "https://example.com/?some_key=some_value"
    let value = params.some_key; // "some_value"
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 04 '22 at 05:42