I’ve seen plenty of sites out there who are still using javascript:openWindow(); to open up a smaller pop-up window. Though the method works very effectively, it makes the spiders unable to crawl the content of that pop-up window. Spiders aren’t able to follow JavaScript links so your pop-up window content won’t make it to the search engines’ indexes at all.
My solution is quite simple, we’re still going to use our old pop up window code but we’re not going to put it in the href attribute but rather on the onclick attribute. Example:
<script type="text/javascript">
function openWindow() {
window.open ("my_new_page.html","mynewwindow");
}
</script>
<a href="my_new_page.html" onclick="javascript:openWindow();return false;">Link</a>
Note that we are now having the page we want to link to in the href attribute. On the onclick, I added our openWindow function with a return false; attached to it. If you attach return false; onto any link, it’ll stop the browser from taking you to a new page. Your openWindow() function will still run, therefor, a new pop-up window opens.
We can also make our openWindow() function more modular by making it accept any link:
<script type="text/javascript">
function openWindow(url) {
window.open (url,"mynewwindow");
}
</script>
<a href="my_new_page.html" onclick="javascript:openWindow(this);return false;">Link</a>
I added the this argument into the openWindow() function. this tells the function to pass the href attribute into the function.
If you want to learn more on how to modify the pop-up window’s width, height, etc., head on over to http://www.javascript-coder.com/window-popup/javascript-window-open.phtml