facebox插件

本文档提供了Facebox 1.2版本的使用教程,包括如何加载依赖项、设置链接以触发Facebox显示不同类型的弹出框(如图片、HTML片段和Ajax加载的内容),以及通过jQuery进行程序化控制的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在网上down下facebox1.2版的源码,

重新整理了下(原来是不兼容ie6的),

附件中jquery用的是1.3版的,我只写了展示图片的弹出层。

 

方法:

Images

View '/facebox/stairs.jpg' in the Facebox

The Code

<a href="stairs.jpg" rel="facebox">text</a>

Divs

View the 'info' div in the Facebox

The Code

<a href="#info" rel="facebox">text</a>

Ajaxes

View 'remote.html' in the Facebox

The Code

<a href="remote.html" rel="facebox">text</a>

Load Dependencies

Make sure jQuery is loaded before Facebox.

<script src="jquery.js" type="text/javascript"></script>
<link href="/facebox/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="/facebox/facebox.js" type="text/javascript"></script>

Attach It onLoad

While calling facebox() on any anchor tag will do the trick, it's easier to give your Faceboxy links a rel="facebox" and hit them all onLoad.

jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox()
})

Extra Classes

You can give the facebox container an extra class (to fine-tune the display of reusable remote pages) with the facebox[.class] rel syntax.

Maybe your Terms and Conditions can be loaded standalone or via Facebox. When loaded in Facebox, you might want to tweak some styles -- like making the h1 positioned absolutely? We do this on FamSpam.

View an an example which makes the remote.html page bigger and bolder using css.

The Code

<a href="remote.html" rel="facebox[.bolder]">text</a>

Controlling Facebox Programmatically

It's possible to attain a higher level control over Facebox by calling methods directly. The following will open the Facebox and insert the passed string into it:

Arbitrary Text

jQuery.facebox('something cool')

If you plan to fill the Facebox with the result of an Ajax call, you'll want the loading graphic displayed whilst your asynchronus task runs. This is the automatic behavior if the facebox() method is passed a function.

Loading Image Displayed

jQuery.facebox(function() {
  jQuery.get('code.js', function(data) {
    jQuery.facebox('<textarea>' + data + '</textarea>')
  })
})

具体教程参见:http://plugins.jquery.com/project/facebox 或者http://famspam.com/facebox

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值