This seems to be a standardised way to tell the type of a javascript object. Why?
Category Archives: JavaScript
A little tweak with Chrome Console
This strange behaviour with console is worth paying attention to: it updates the object when you expand it. Say we have:
jQuery: Difference between bind, live and on
Equivalent:
$('button').bind('click', fn); $('button').on('click', fn);
Equivalent:
$('button').live('click', fn); $(document.body).on('click', 'button', fn);
Facebook: Share, Like, Comment
This is how to utilise the Facebook JavaScript SDK to add Share, Like and Comment for your site:
The order of the events triggered will be in the order they’re added. So when the order of two events makes a difference, and they’re in separate files, pay extra attention to which one gets load first. Especially when the page loads extra slow.
Order of On Events
Compatible Audio Playing Across All Platforms
It seems like:
- With HTML5 audio tag, if the audio is less than 500ms, the volume in Safari might fluctuate with all formats
- With HTML5 audio tag, the delay with Safari is obvious with all formats
- With flash audio player, the delay with Safari is obvious with
*.wav
, but it’s fine with*.mp3
- IE9 doesn’t support native audio tag
- Firefox’s audio sounds terrible when html5 audio tag is used with
mp3
/ogg
format, but is okay withwav
. - Firefox is fine with flash audio player
jQuery: keyup, keydown, keypress?
In normal cases, go for keyup
:
$(document).keyup(function(e){
console.log(e.which);
});
Reasons:
keydown
keeps firing when user holds the keys down, whilekeypress
andkeyup
fire only once.keypress
doesn’t detect special keys (e.g.SHIFT
),keydown
andkeyup
do.
IOS Video Control: Mission Impossible?
I spent 1.5 hours deleting code and comparing and found that JavaScript initiated events just can’t get the video going. One all-mighty Googling [1][2] revealed that, “embedded media cannot be played automatically in Safari on iOS – the user always initiates playback.” Damn.
It looks like a dead end. But wait. How did videojs-youtube managed it?