First, I am getting the URL of the website currently open and storing that value inside a variable. Then I declare a new variable which adds "view-source:" + the variable with the URL I had previously declared. This prints out the address to the source code of said website.
I want to be able to use window.open so that the new value stored in the second variable is used as the URL inside the parameters. Here is my code:
let page = window.location.href;
let sourcecode = "view-source:" + page;
window.open(sourcecode);
How can I achieve this? Alternatively, is there a way to open the source code directly through JavaScript? Thanks.