I was wondering if it's possible to load a bit of JavaScript from within an iframe. It seems that this questions has been answered [here](https://stackoverflow.com/questions/935127/how-to-access-parent-iframe-from-javascript). 

However, the reason I ask is that the iframe is loaded from an external source (i.e. an adserver) and then get's the time from the users machine. What I am trying to do is calculate how long is spent on the page when this iframe is loaded (and then potentially pass this value back to a server).

I know there aren't any code samples in this questions but if someone has come across something like this before please let me know. I always thought there would be some sort of security issue with this i.e. calling an iframe on a page and then that iframe running a script which effectively "gets" something (even if it's just the time) from your machine.

Thanks