Hi,
I am trying to load HTML code and display it on my site based on the URL parameters.
I want it to work like this. My shortcut (Siri Shortcuts) will redirect people to https://example.com/index.html?page=[HTML CODE HERE]
. Then the HTML code that is in that URL variable, will display on the site (not the blank text but overwrite the existing code so it will display that HTML page). The problem is I am doing it with this code below.
window.onload = function() {
try {
var url_string = (window.location.href).toLowerCase();
var url = new URL(url_string);
var page = url.searchParams.get("page");
document.write(page);
}
}
It works fine when I want it to output 'test' (https://example.com/index.html?page=test
). But when I put the whole HTML code in the url variable, it won't output anything.
NOTE: I am still new to HTML and JS.