Javascript redirect

Upon the user’s initial page visit, a cookie is sent to the computer. When the user opens the page in a new tab, the presence of the cookie is checked. If it exists, the browser opens the specified link. My goal is to use JavaScript within a blank iframe to create a redirect that leads to a URL in a new window or tab.


My aim is to use Javascript within an empty iframe to establish a redirect that will lead to a URL within a fresh window or tab.

To be more precise, my goal is to redirect a Facebook tab to our company’s webpage instead of displaying it within the tab’s iframe, which doesn’t match the width of our web page.

I already possess a redirect script, however, it fails to open the URL in a separate window.

Upon page load, this code snippet attempts to open a new window, but Chrome’s pop-up blocker prevents it. This oversight only occurred to me now. Perhaps I can modify it to load in a lighter window instead.

Solution 1:

Here you go: Jsfiddle Example

function opennewtab(url){
    var win =, '_blank');

Solution 2:


Frequently Asked Questions