The company blamed its under-performing online ad business for its first loss in 26 years of public trading.