页面加载时自动打开jQuery ColorBox [英] Open jQuery ColorBox automatically on page load
本文介绍了页面加载时自动打开jQuery ColorBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将colorbox jQuery lightbox用于我的灯箱.但是在那应该点击按钮.我想在加载窗口时自动弹出.
I have used the colorbox jQuery lightbox for my lightbox. But in that one should click the button. I want automatically popup whenever the window is loaded.
我的灯箱代码是
<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>
现在,我想在加载窗口时自动弹出.
Now I want to an automatic popup when the window is loaded.
推荐答案
使用最新版本的 ColorBox ,则使用$.colorbox({inline:true, href:".ajax"});
工作演示: http://jsfiddle.net/34v22/
我还整理了一下您的代码:
With the latest version of ColorBox, you use $.colorbox({inline:true, href:".ajax"});
Working demo: http://jsfiddle.net/34v22/
I also cleaned up your code a bit:
<!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 ColorBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文