使用像Javascript Alert这样的fancybox显示内容 [英] Show content with fancybox like a Javascript Alert

查看:77
本文介绍了使用像Javascript Alert这样的fancybox显示内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在fancybox中显示来自PHP文件的内容,但我无法处理它。

I try to show the content from a PHP-file in a fancybox but I can't handle it.

现在出现以下情况:
如果出现文件权限问题,则会在网站上显示< div id =error> 。我想在fancybox中提供< div id =error> 中的内容。我尝试的所有内容都会收到通知无法加载请求的内容。请稍后重试。

Now it's the following situation: If a file permission problem occures a <div id="error"> is shown on the website. I'd like to have the content from <div id="error"> in fancybox. Everything I try I get the notice "The requested content cannot be loaded. Please try again later."

这意味着fancybox,文件权限错误发生,应该是在页面加载时显示,而不是像点击或鼠标悬停等某些事件时显示的那样。

That means the fancybox, it the file permission error occures, should be shown when the page is loading and not like usual shown when some events like click or mouseover.

例如,如果错误存在,则应在fancybox:

For example, if the error exists, the following content should be shown in the fancybox:

<div style="width:100px; height:100px; background:#f00;">
  <p>Failure</p>
</div>

此代码段位于文件 security_check.php 。现在有两种可能性。第一个是将 security_check.php 直接加载到fancybox中或者放入上面提到的代码段。

This snippet is located in a file security_check.php. Now there are two possibilities. The 1st is to load the security_check.php directly into the fancybox or to put in the mentioned above snippet.

那么:如何将文件内容加载到fancybox?

So: how to load file contents into the fancybox?

推荐答案

有这样的代码将文件内容加载到持有fancybox的DIV中内容:

Have such code to load the file contents into the DIV holding the fancybox contents:

$(function() {
    $("#MyFancyContents").load("security_check.php");
});

fancybox链接应该是这样的:

The fancybox link should then be something like:

<a id="MyFancyLink" href="#MyFancyContents">Show</a>

要激活,你可能拥有的东西:

And to activate, what you probably already have:

$("#MyFancyLink").fancybox();

编辑:为了在页面加载时激活精美框,而不仅仅是点击链接,换句话说:

in order to activate the fancy box when page loads rather than just by clicking the link, have such line instead:

$("#MyFancyLink").fancybox().trigger('click');

这篇关于使用像Javascript Alert这样的fancybox显示内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆