Wednesday 9 May 2012

Avoid frames on your website

HTMLSome sites to keep the visitors on their own URL establish a link to your site posted inside a frame, i.e. one of HTML elements <object> (the only one still valid) <frame> ou <iframe>..

This is the case for example in search engines Google and Yahoo/Bing, during the search for images. They display a big image with your site in background for the first and on the bottom for the second. This is a hateful method, particularly from these rich web giants, which instead sending you traffic only facilitates the theft of your images. :-/

We can fight with a small and simple code in Javascript which will allow you to redisplay systematically your site on a full page, with its URL in the address bar.

~

/* To avoid frame in search engines: */
if (top != self)
  top.location.href = location.href;

~

This code must be placed where it will be executed, i.e. in a Javascript file called by all the pages of your site (as on this present site, I put it in comments.js who is loaded on each page), or in HTML code, between the <head> element, where preferably the Javascript must be. In this last case, do not forget the <script> element with the good parameter (the langage="Javascript" attribute does not exist!) and the small escape things! ;-)


<script type="text/javascript">//<![CDATA[
/* The code here */
//]]></script>


cafĂ© Did this article help you? 
Buy me a coffee!

Leave a comment (all comments are moderated, don't waste time with spam)

Azure Dev