如何将文本数据而不是图像放入灯箱
how to put text data in lightbox instead of images
是否可以将文本内容放入框架中,并在灯箱中显示,而不是显示图像?
我该怎么做?
我试过了
<a class="iframe" href="/folder/file.txt"><img height="80" width="120" src="img/txtFile.png"</a>
并在 jquery
<script type="text/javascript">
$("a.iframe").fancybox({
'width': 640, // or whatever you want
'height': 480, // or whatever you want
'type': 'iframe'
});
</script>
Fancybox能够显示多种类型的内容。查看他们的 documentation for more information. This includes inline content (ie displaying a hidden element, like a div), loading an iframe, or displaying an ajax response. The examples 部分可以帮助您澄清很多内容。
如果您想从 txt 文件中读取数据,通过 ajax 加载数据可能比将数据加载到 iframe 中更合适。
我已经从上面列出的文档 link 中复制了相关文档,以供后代使用(您可以在这个 codepen demo 中查看 fancyapps 团队设置的示例):
Ajax
To load content via AJAX, you need to add a data-type="ajax"
attribute to your link:
<a data-fancybox data-type="ajax" data-src="my_page.com/path/to/ajax/" href="javascript:;">
AJAX content
</a>
Additionally it is possible to define a selector with the data-filter
attribute to show only a part of the response. The selector can be any
string, that is a valid jQuery selector:
<a data-fancybox data-type="ajax" data-src="my_page.com/path/to/ajax/" data-filter="#two" href="javascript:;">
AJAX content
</a>
是否可以将文本内容放入框架中,并在灯箱中显示,而不是显示图像? 我该怎么做?
我试过了
<a class="iframe" href="/folder/file.txt"><img height="80" width="120" src="img/txtFile.png"</a>
并在 jquery
<script type="text/javascript">
$("a.iframe").fancybox({
'width': 640, // or whatever you want
'height': 480, // or whatever you want
'type': 'iframe'
});
</script>
Fancybox能够显示多种类型的内容。查看他们的 documentation for more information. This includes inline content (ie displaying a hidden element, like a div), loading an iframe, or displaying an ajax response. The examples 部分可以帮助您澄清很多内容。
如果您想从 txt 文件中读取数据,通过 ajax 加载数据可能比将数据加载到 iframe 中更合适。
我已经从上面列出的文档 link 中复制了相关文档,以供后代使用(您可以在这个 codepen demo 中查看 fancyapps 团队设置的示例):
Ajax
To load content via AJAX, you need to add a
data-type="ajax"
attribute to your link:<a data-fancybox data-type="ajax" data-src="my_page.com/path/to/ajax/" href="javascript:;"> AJAX content </a>
Additionally it is possible to define a selector with the data-filter attribute to show only a part of the response. The selector can be any string, that is a valid jQuery selector:
<a data-fancybox data-type="ajax" data-src="my_page.com/path/to/ajax/" data-filter="#two" href="javascript:;"> AJAX content </a>