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

Fails to load content in directory above current one #867

Closed MrAnalogy closed 5 years ago

MrAnalogy commented 5 years ago

I'm using the "display from html" without attaching it to an event handler.

IT works as long as the HREF is in the same directory or a a sub directory. But content never loads if the page being loaded is above the current page.

ASSUME: Directory html/sub1 html and sub1 both contain a file coaching.htm and there is an index.html file in /sub1 that contains the html below:

//this fails (it never loads) personal coaching

//this succeeds personal coaching

I also tried href: "./coaching.html" (since html/ is the root directory)

MrAnalogy commented 5 years ago

I created a sample to demonstrate the problem. https://www.bungalowsoftware.com/test/colorbox.htm#

The link "Example of Problem" illustrates the problem.

jackmoore commented 5 years ago

jQuery failed to parse that page you are loading through ajax and is throwing an error. This doesn't actually have anything to do with the location/directory of the document nor does it have anything specifically to do with Colorbox (other that it uses jQuery's ajax). I would suggest using Colorbox's iframe property to load whole documents (instead of HTML snippets) so that the document is sandboxed rather than parsed into your current document. The way jQuery does handles documents in ajax is that it will parse that page for scripts and run them on the current document, which is probably not what you want.