I have a modal frame popup, and would like to run some jQuery code after it loads. I can't seem to get the onLoad event to fire. Here's my code:

var modalFrameOptions = {
  url : "http://google.com",
  width : 800,
  height : 600
};
modalFrameOptions.onLoad = function(modalFrame, $iFrameWindow, $iFrameDocument) {
  alert('child onLoad ran');
}
Drupal.modalFrame.open(modalFrameOptions);

The dialog pops up but no alert is displayed.

I have also tried:

var modalFrameOptions = {
  url : "http://google.com",
  width : 800,
  height : 600,
  onLoad : documentLoad()
};
Drupal.modalFrame.open(modalFrameOptions);

function documentLoad(modalFrame, $iFrameWindow, $iFrameDocument) {
  alert('commentFormLoad');
  alert(modalFrame);
  alert($iFrameWindow);
  alert($iFrameDocument);
}

In this case, the alerts display, but all of the argument objects are "undefined".

Is there some other way to manipulate the child modal popup with jQuery?

Thanks for your help!

Comments

captaindav’s picture

I should have specified "valid_Drupal_path" rather than "http://google.com" as the url. The url I am displaying in the model frame is a local Drupal path on the same domain.

dsnopek’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

onLoad won't work when you open a URL on another domain due to cross-domain security.