javascript Fancybox 不会加载内联内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3754792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 02:08:36  来源:igfitidea点击:

Fancybox won't load inline content

javascriptjqueryhtmlfancybox

提问by Mathias Schnell

To make things easy, here's the site - http://schnell.dreamhosters.com/folio/pixelread.phpView the source code all you like.

为方便起见,这里是该站点 - http://schnell.dreamhosters.com/folio/pixelread.php查看您喜欢的所有源代码。

The middle button of the top bar in your browser window that says "Palette" is supposed to open up a fancybox in the middle of the screen, and that box should load into it the data inside the element with id of 'data', but it doesn't and comes up with an error message of "The requested content cannot be loaded. Please try again later." I took this example straight from the fancybox website and double-checked that all the CSS, image and JS files are in their proper place and loaded. So now I'm lost and no idea how to do/fix this.

浏览器窗口顶部栏的中间按钮,上面写着“Palette”应该在屏幕中间打开一个fancybox,并且该框应该将id为“data”的元素内的数据加载到其中,但是它没有并出现“无法加载请求的内容。请稍后再试”的错误消息。我直接从fancybox 网站上获取了这个示例,并仔细检查了所有CSS、图像和JS 文件是否都在其正确的位置并已加载。所以现在我迷路了,不知道如何做/解决这个问题。

PS - I use Google Chrome 6.0. I'll see if this happens in IE8 or Firefox.

PS - 我使用谷歌浏览器 6.0。我会看看这是否发生在 IE8 或 Firefox 中。

PPS - Found a solution. I can force the HTML content that goes into a fancybox by using the 'content' property. Using that and jQuery I can easily stuff a box with whatever I want. Thanks for the help guys.

PPS - 找到了解决方案。我可以通过使用 'content' 属性来强制将 HTML 内容放入一个fancybox。使用它和 jQuery,我可以轻松地将我想要的任何东西塞进一个盒子里。谢谢你们的帮助。

采纳答案by Mathias Schnell

Found a solution. I can force the HTML content that goes into a fancybox by using the 'content' property. Using that and jQuery I can easily stuff a box with whatever I want. Thanks for the help guys.

找到了解决办法。我可以通过使用 'content' 属性来强制将 HTML 内容放入一个fancybox。使用它和 jQuery,我可以轻松地将我想要的任何东西塞进一个盒子里。谢谢你们的帮助。

回答by idrumgood

I think the problem is that fancybox isn't recognizing your content as being inline (not exactly sure why, but maybe something to do with the query string in the url, since it works when that isn't present).

我认为问题在于fancybox 无法将您的内容识别为内联内容(不确定为什么,但可能与url 中的查询字符串有关,因为它在不存在时有效)。

I would try adding the explicit type: inlineto your fancybox declaration:

我会尝试将显式添加type: inline到您的花式盒声明中:

$("a#inline").fancybox({'type':'inline'});