我在我的灯箱中使用了 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/