0

我现在正面临fancybox的问题。我有一个网站,上面有文章的链接,点击后会显示在花式框中。

现在,当直接访问一篇文章时,会检测到这一点,并将用户重定向到索引页面,并将文章 ID 作为参数。我在索引页面上检测到这一点,并想立即在fancybox 中打开该文章。

这是我使用的代码:

[...] //finding out if parameter is passed and storing it in id
$.fancybox.open([
{
  href:'localhost/article.php?p='+id,
  title: 'test title'
}],
{
  padding :0
});
[...]

此代码取自 fancybox 文档。运行此程序时,没有显示灯箱,但奇怪的是,只要我用 localhost/article.jpg 替换 href,fancybox 就会触发并显示一个框(包含错误,内容内容无法找到等)。

现在的问题是:我是否需要不同的语法/一些特殊设置才能从代码中打开 php 或 html 页面?

4

1 回答 1

1
[...] //finding out if parameter is passed and storing it in id
$.fancybox.open([
{
  href:'localhost/article.php?p='+id,
  title: 'test title'
}],
{
  padding :0
});
[...]

尝试分离你的参数。


我认为问题可能在于fancybox 无法确定它应该使用iframe。尝试添加类型选项,它对我有用。

$.fancybox.open([{
    href: 'localhost/article.php?p='+id,
    title: 'test title'
}], {
    type: 'iframe',
    padding: 0
});
于 2013-10-25T06:35:29.770 回答