简体   繁体   English

使用Fancybox将div显示为弹出窗口

[英]Show a div as pop-up using Fancybox

I need to show a div with application form as a pop-up using fancybox. 我需要显示一个带有应用程序表单的div作为使用fancybox的弹出窗口。 Is it possible to .fancybox() anything but image because all the tutorials i came across on the internet use . 是否可以.fancybox()除了图像以外的任何内容,因为我在互联网上遇到的所有教程都使用。

Thanks in advance! 提前致谢!

I have the following code: 我有以下代码:

<input type="button" value="Preview" id="btnPreview" />

testen text! 测试文本!
 <script type="text/javascript"> $(document).ready(function () { $('#divDetails').hide(); $('#divPreview').hide(); $('.image').click(function () { var imgPath = $(this).attr('src'); var imgName = imgPath.substring(0, imgPath.length - 4); var imgAlt = $(this).attr('alt'); $('#mainDiv').hide(); $('#divDetails').show('slow'); $('#detailedImage').attr('src', imgName + '-large.jpg').attr('alt', imgAlt); }); $('#btnPreview').click(function () { $('#divDetails').show(); $("#divPreview").fancybox(); }); }) </script> 

The rest of the code is not relevant. 其余代码无关。 when I click the btnPreview button I want the div with ID divPreview to pop-up and I call $("#divPreview").fancybox(); 当我单击btnPreview按钮时,我要弹出ID为divPreview的div,然后调用$(“#divPreview”)。fancybox();。

I include these scripts 我包括这些脚本

 <link href="../css/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" /> <script src="Scripts/jquery-1.6.2.min.js" type="text/javascript"></script> <script src="../fancybox/jquery.fancybox-1.3.4.pack.js" type="text/javascript"></script> <script src="../fancybox/jquery.mousewheel-3.0.4.pack.js" type="text/javascript"></script> <script src="../fancybox/jquery.easing-1.3.pack.js" type="text/javascript"></script> 

What am I doing wrong? 我究竟做错了什么?

Thank you!! 谢谢!!

Give some more information please... What context? 请提供更多信息...什么情况? What is your html? 你的HTML是什么?

Possible mistakes: 可能的错误:

1) jQuery is not loaded before you run this snippet (include it as first) 2) One or both id's are not found. 1)在运行此代码段之前,jQuery未加载(首先包含它)2)找不到一个或两个ID。 3) fancybox is not included before you run this snippet. 3)在运行此片段之前,不包含fancybox。

I personally use prettyPhoto, its very simlar to fancy box, however Ive found it to be more compatible with older browsers. 我个人使用了prettyPhoto,它非常类似于花哨的盒子,但是Ive发现它与旧的浏览器更加兼容。

have a look 看一看

http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/ http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/

I belive the page you are looking for, for loading custom content is here 我相信您正在寻找的页面,用于加载自定义内容在这里

http://www.no-margin-for-errors.com/blog/2010/09/28/tutorial-opening-custom-content-in-prettyphoto/ http://www.no-margin-for-errors.com/blog/2010/09/28/tutorial-opening-custom-content-in-prettyphoto/

In that example they use a google maps :) 在那个例子中,他们使用谷歌地图:)

Hope this helps you out. 希望这可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM