Have an iframe on a Visualforce page that's src is from an external site. The iframe has a button that's used to send a recording off via email from that external site. I'm trying to see if it's possible to add some JavaScript to capture the DateTime when that button is clicked. Been getting some unreliable data back from the external site about when users are sending the email, so we want to see if we can capture that on our end instead.


You can add a listener with JS to the iFrame


var iframe = document.getElementById('myIFrame');
iframe.contentDocument.body.addEventListener('mouseup', Handler);

function Handler() {
    alert(new Date());
  • Rather inaccurate to check on the entire iframe itself for a mouseup event, but an interesting idea. I'll give it more consideration.
    – Tim Hunter
    Mar 31 '21 at 19:45
  • To get the button itself, can also get the contentWindow.document of the iFrame and look for the element itself
    – tik27
    Mar 31 '21 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.