Html5detect v0.2

Just a quick update. Today I thought about a way of intercepting messages that are being send – v0.1 only detects and display’s post messages that are received. The technique is used quite often and is not new but still very useful. In javascript you’re allowed to override native browser function. So this means that I can read and write the browser function ‘postMessage’. All I need to do is override the current browser function with my own and call the old browser function at the end of mine. If this makes little sense here is the code:

var postMessageORIG = window.postMessage;
    window.postMessage = function(message, destination){
    console.log("Sending: ", message, destination);
    postMessageORIG(message, destination);
}

Thats it, new code is on GitHub.

Cheers, Ruben.

Comments