Here is the method which is used in Commerce SagePay and in Commerce Paypoint Drupal modules which basically compares document.location.href with the old value by first loading its own iframe, then external one.
So basically the idea is to load the blank page as a placeholder with its own JS code and hidden form. Then parent JS code will submit that hidden form where its #action points to the external iframe. Once the redirect/submit happens, the JS code which still running on that page can track your document.location.href value changes.
Here is example JS used in iframe:
;(function($) {
Drupal.behaviors.commercePayPointIFrame = {
attach: function (context, settings) {
if (top.location != location) {
$('html').hide();
top.location.href = document.location.href;
}
}
}
})(jQuery);
And here is JS used in parent page:
;(function($) {
/**
* Automatically submit the hidden form that points to the iframe.
*/
Drupal.behaviors.commercePayPoint = {
attach: function (context, settings) {
$('div.payment-redirect-form form', context).submit();
$('div.payment-redirect-form #edit-submit', context).hide();
$('div.payment-redirect-form .checkout-help', context).hide();
}
}
})(jQuery);
Then in temporary blank landing page you need to include the form which will redirect to the external page.
srcproperty change when a link in the iframe is clicked? I'm not sure about that - if I had to guess, if would say "no". There are ways to monitor properties (in Firefox at least AFAIK) but I'm not sure whether it will be of any use in this case. - Pekkasrcattribute in the DOM does not change in the latest versions of either FireFox or Safari. @Michiel's answer below is as good as I have been able to get so far. - Kaelin Colclasure