I have given an answer on Stack Overflow and it is working on jsfiddle plus my local machine but people are complaining that that it doesn't work (gives any output) to them.
So I tried to check it from chrome and got this error on Consol:e
Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Sandbox access violation: Blocked a frame at "http://stacksnippets.net" from accessing a frame at "null". Both frames are sandboxed and lack the "allow-same-origin" flag.
In IE 11 it's giving "Access is denied" error.
For reference, the link to my answer is here.