I have a function that's supposed to copy window.location.origin
to the clipboard for the user to paste:
<OptionButton
onClick={() => this.copyLink(`${window.location.origin}/calc/${apiId}/${formatScenarioName(database.api.scenarioName || database.inputs.scenarioName)}`)}
>
Copy Link
</OptionButton>
copyLink(value) {
const tempInput = document.createElement('input')
tempInput.style = 'position: absolute; left: -1000px; top: -1000px'
tempInput.value = value
document.body.appendChild(tempInput)
tempInput.select()
document.execCommand('copy')
document.body.removeChild(tempInput)
message.success('Link copied to clipboard!')
}
While this works on any other browser, this fails on IE11. I've tried incorporating react router, but the requirement is to have the full link rather than just the params. However a workaround I've also tried is plainly adding window.location.href
, but that's not very dynamic.
Is there a polyfill for this on IE11? Or a workaround to this?