Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Forcing Your Facebook App To Run Using HTTPS / SSL

Forcing Your Facebook App To Run Using HTTPS / SSL

0

Providing your Facebook App supports HTTPS / SSL, you may prefer to force all users to use a secure connection – especially if you plan to deal with sensitive information such as credit card numbers, personal details etc.

Luckily, JavaScript offers a easy method for detecting non-secure connections and then forcing them to use a secure connection instead. The solution works by checking what connection the user is using. On a non-secure connection (i.e. HTTP), the JavaScript code will redirect the parent frame (i.e. Facebook) to the secure version of the app, forcing the iFrame to load securely too.

The solution is:

<script type="text/javascript">
if ( window.location.protocol == 'http:' ) {
    window.top.location = 'https://www.facebook.com/yourapp';
}
</script>
Facebook, JavaScript, SSL

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy