Opening a New Window From a Web Page with Javascript that is SEO Friendly

The days of <a href=”#” target=”_blank”></a> are long gone.? The way to open a new window with a link is to do it using the javascript window.open() method via an onclick callback.

However, you still want to make your pages SEO friendly, so you don’t want to go about generating links with href=”#”.? The way to do it is as follows:

Javascript:

<script>

function openNewWindow(url) {

   window.open(url);

}

</script>

HTML:

<a href=”someURL.html” onclick=”openNewWindow(‘someUrl.html’);return false;”>Link</a>

When implementing links this way, you still include the url in the href attribute making the page SEO friendly and implement the new window functionality via your javascript function.? You must make sure to include return false; in your onclick attribute so that the link doesn’t load in the window from which the original click was issued.

Leave a Reply