I am trying to make a website login page that has a button at the top that closes the page, but when I try to use window.close(), self.close() or the close() functions it gives me the error:
Scripts may close only the windows that were opened by them.
I have tried searching google but there seems to be no answers on the internet. I am testing the file using chrome.
I wrote this javascript:
<script>
function closeTab() {
window.close()
}
</script>
And this HTML for the image im trying to make as a close button:
<img onClick="closeTab()" src="image_source.svg" alt="Close Button">
Click here to see the error in the console.
Any help would be greatly appreciated, Thanks.