Make sure to check the update at the end of the article. 

There is a handy piece of Javascript which you can use to tell if the current page is within the Facebook canvas iframe, or if it is being viewed normally in the browser.

The Facebook canvas gives its window a special "name" attribute. In most cases unless you generated the browsing window, it will have no name so we can use the piece of code below.

  if(window.name != "") {
    //We are on Facebook
  } 
  else
  {
    //We are just in the normal browser window
  }

However, if you changed your window name through Javascript, change the IF statement to match.

With this information, we can hide, add or manipulate our HTML in any way that is required to highlight the difference between your Facebook app and the regular web app.

 

Update Feb 2016:

As noted by Kilian in the comment section, an imporved way to detect the Facebook iframe is:

if(window.name.indexOf('iframecanvasfb') > -1)