I'm writing a website for my own use which I am not planning to put on any public domain. It's been a few months since I have done anything to advance this project, and as such, I had to read over it a bit before continuing. The problem I had, appeared when I run the program. I seem to be getting an error that I pasted below:
Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
I had done a bit of research and it appears to be caused by browser thinking I'm trying to read the href of a parent document from an iframe. Whilst this is what I am doing, the domains are the same since I'm only running the scripts locally, and I'm not accessing any internet files. Through my research I did, I found out that this error has something to do with security with cross domain scripting that can be a security risk. Below I pasted the line that gives me the error:
if (window.top.location.href.includes("/Character.html")) {
window.top.location.href = "main.html?page=Character.html";
} else if (window.top.location.href.includes("/main.html")) {
//...
The above check is in order that if I accidentally open the Character.html page, it'll redirect me to the main page and load up the character page in an iframe. (That way I have the entire website navigation from the main page on all pages) Is there a way I can check the top location without triggering an error? I have tried document.referrer but it seems to not return the desired value. Perhaps there is a round about way that will do what I am trying to do?
Also, I believe when I was testing it a few months ago on Firefox on a Linux it worked (Chrome gave me the same error but I'm not sure it was because of the same reason)