Monday, 30 April 2012

Twitter Bootstrap datepicker British format dd/mm/yyyy

This morning I've been using Scott Storborg's Twitter Bootstrap datepicker (which I believe he has now pulled from Github), which looks and works beautifully, but wasn't in my required date format. I couldn't find much documentation on how this might be modified, but I figured out the following works:

Friday, 27 April 2012

Cross-browser safe javascript console logging

You can keep this in your js code and it won't error on non-supporting browsers:
if(window.console.log&&window.console){window.console.log('This is safe!');}

Friday, 13 April 2012

Setting a P3P header in Rails - Session cookies in iframes in IE

Friday 13th, and today I spent far too long battling with a problem that I should have recalled from a previous skirmish. Never shall I forget again!

Some versions of IE, on some versions of Windows, have stricter policies regarding 3rd party content served through an iframe. Confusingly, the same browser (IE8 for example) will behave differently on different Win versions: some will allow session cookies, and some won't. You know you've been nobbled when you see the evil eye at the bottom of the browser with a red sign on it.

The way round this is to send a P3P header with a compact privacy policy in your iframed content:
class ApplicationController < ActionController::Base
  before_filter :set_p3p
    # for IE session cookies thru iframe
    def set_p3p
      headers['P3P'] = 'CP="ALL DSP COR CURa ADMa DEVa OUR IND COM NAV"'