jquery - 页面加载时自动打开 jQuery ColorBox

标签 jquery colorbox

我在我的灯箱中使用了 colorbox jQuery lightbox。但其中应该单击按钮。我希望在加载窗口时自动弹出。

我的灯箱代码是

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
        <script src="../jquery.colorbox.js"></script>
        <script>
            $(document).ready(function(){
                $(".ajax").colorbox();
            });
        </script>
    </head>
    <body>

        <h2>Other Content Types</h2>
        <p><a class='ajax' href="../content/daisy.jpg" title="Homer Defined">Outside HTML (Ajax)</a></p>
</html>

现在我想在加载窗口时自动弹出。

最佳答案

使用最新版本ColorBox ,您使用 $.colorbox({inline:true, href:".ajax"});

工作演示:http://jsfiddle.net/34v22/

我还清理了你的代码:

<!doctype html>
<head>
    <title>My Automatic ColorBox</title>
    <link rel="stylesheet" type="text/css" href="../link/to/jquery.colorbox.css">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script type="text/javascript" src="../jquery.colorbox.js"></script>
    <script>$(document).ready(function(){$.colorbox({inline:true, href:".ajax"});});</script>
</head>
<body>
    <h2>Other Content Types</h2>
    <div class='ajax' style='display:none'><a href="../content/daisy.jpg" title="Homer Defined">Outside HTML (Ajax)</a></div>
</body>

关于jquery - 页面加载时自动打开 jQuery ColorBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14778561/

相关文章:

javascript - 如何在鼠标悬停时使 div 出现在图像上的特定区域标签上?

面向 ColdFusion 开发人员的 jQuery Ajax 插件

jQuery 验证 : show one message per time

jquery - 在 Chrome 中打印隐藏 DIV 中的图像失败

drupal - 在彩盒中显示评论表和其他信息以及图像

matrix - gnuplot "matrix with image"对于某个值具有固定颜色

php - 如何在不使用 php 拇指的情况下获取多种尺寸的图像?

jquery - Colorbox iframe 重定向到页面

jquery - 使用 colorbox jquery 插件加载部分(外部)html 页面

javascript - 单击时显示随机 div