jackmoore / colorbox

A light-weight, customizable lightbox plugin for jQuery
http://www.jacklmoore.com/colorbox/
MIT License
4.75k stars 1.14k forks source link

Colorbox throwing uncaught rangerror errors and freezing browser #747

Open W1DJM opened 9 years ago

W1DJM commented 9 years ago

I am trying to use Colorbox to display several pages which are under the control of and loaded by a single PHP page. Since Colorbox is used by multiple included pages I have it defined in the single (master) PHP page so it is always available.

What I am experiencing is a browser lockup after 3 to 5 links on the master page have been clicked and Colorbox has been called. I have created a very simple page that displays its own content to illustrate the problem:

http://dynacompsolutions.com/colorbox/colorbox.php

I have tried Jquery versions 1.11.2, 1.11.3 and 2.1.4 with the latest version of Colorbox and they all fail the same way. I understand what the error message is trying to tell me but, for the life of me, I don't see anything that should be causing a recursive call.

Thanks in advance, Dave

jackmoore commented 9 years ago

Hm... might could add additional checking to avoid this, but you really shouldn't ever be doing what you are currently doing. You are loading in an entire HTML document into an existing document with ajax, which results in invalid HTML and duplicate loading of scripts and their effects. In this case it's assigning Colorbox to the same link each time, as well as loading additional versions of jQuery. When you load a page with ajax, jQuery is going to search it for script tags and add them to the current document. You should either use an iframe, or just load the portion of HTML you want to show (minus the scripts).

W1DJM commented 9 years ago

Thanks for the response Jack and pardon the interrupt. I tried simply adding iframe:true but that resulted in a tiny little rectangle in the middle of the browser with no content. What you describe is probably the correct solution if I can get it to work.

I updated the example at the link above to show what happens when iframe:true is added.

jackmoore commented 9 years ago

Colorbox doesn't attempt to measure the size of iframe content, so you would have to specify a width and height.

On Fri, Aug 21, 2015 at 1:31 PM, Dave Martin notifications@github.com wrote:

Thanks for the response Jack and pardon the interrupt. I tried simply adding iframe:true but that resulted in a tiny little rectangle in the middle of the browser with no content. What you describe is probably the correct solution if I can get it to work.

I updated the example at the link above to show what happens when iframe:true is added.

— Reply to this email directly or view it on GitHub https://github.com/jackmoore/colorbox/issues/747#issuecomment-133505345.

W1DJM commented 9 years ago

Thanks, apparently initialheight and initialwidth aren't enough. Appreciate your support and quick response.