With both the external iframe and colorbox modules installed, I've noticed that the colorbox window cannot be used after a javascript error is caused from the external iframe javascript being run. I've seen this on user PCs, and generated the issue myself using a Windows Vista + Internet Explorer 7 virtual machine.
Steps to reproduce
- Install + enable External iFrame 7.x-2.x-dev
- Install + enable Colorbox 7.x-2.x-dev
- Setup an image with Colorbox as the display type, and enable external iframe on the content type
- In Internet Explorer 7 click an image to open the Colorbox modal
- A javascript error from external_iframe.js should cause colorbox to stop responding
- Install External iFrame 7.x-2.x-dev
Lack of Array indexOf support
The root cause is the lack of Array indexOf support in Internet Explorer versions < 9. This javascript function is used in various places in Drupal without issue, but in this case it prevents colorbox from working properly, forcing the user to use the back button to get rid of the image popup.
Fixes
I chose to put the following at the top of my external_iframe.js file to remedy the issue (code taken from here):
// Add ECMA262-5 Array methods if not supported natively
//
if (!('indexOf' in Array.prototype)) {
Array.prototype.indexOf= function(find, i /*opt*/) {
if (i===undefined) i= 0;
if (i<0) i+= this.length;
if (i<0) i= 0;
for (var n= this.length; i<n; i++)
if (i in this && this[i]===find)
return i;
return -1;
};
}See this Stack Overflow question for detailed information on the issue
I'm not sure what the best option is here, but following this post I will attach a patch with the above fix. This method seems cleaner to me than replacing the indexOf calls with the jQuery equivalent, or pulling in a js library.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | external-iframe-fix-ie6-ie8-js-2055945-1.patch | 687 bytes | rudetrue |
Comments
Comment #1
rudetrue commentedComment #2
kevinsiji commentedTested in IE8 (Win XP). Success. This patch let my Galleria slideshow to run smoothly which was otherwise hopelessly broken.
Comment #3
codesmithPatch works for me. Can we get this committed?