Roecrew Roecrew - 5 months ago 35
Javascript Question

window.location.href redirects to blank page

I'm building a website ( that looks like this.

enter image description here

And I have the following code for detecting a click on the linkedin div, it then redirects.

<script src=""></script>
window.location.href = "";
return false;
<div id="banner">
<div class="menubutton" id="home">Home</div>
<div class="menubutton" id="circuitry">Circuitry</div>
<div class="menubutton" id="programming">Programming</div>
<div class="menubutton" id="stackoverflow">Stackoverflow</div>
<div class="menubutton" id="linkedin">Linkin</div>

But when I click the div, it redirects to a blank page.

enter image description here

What am I missing?


The issue occurs because your entire site is made up of frames/iframes, so when you use window.location.href = "" you'll prompt the browser to open that page in the iframe which isn't allowed by the source, in this case linkedin. Refused to display '' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

To work around this issue you'll need to use instead of window.location, e.g:'', '_blank');

On a side note, I would recommend to not iframe the source content of the page and instead setting up a CNAME for your for your domain which points at your IP, because the IP is concurrently exposed in the DOM.