Suggest you implement a try / catch JavaScript block that throws an error for some hidden form control in an IFrame:
try{ //your javascript that can throw an error } catch(e) { document.getElementById("YourHiddenControlId").value = e.Message; }
Then you can access the form variable in the IFRame.
source share