我需要在window.onload事件中用colorbox插件打开一个iframe。我几乎获得成功,但一些奇怪的事情开始发生。让 - 我给上面的例子正常工作:jQuery colorbox奇怪地失败
<script src="../jquery.colorbox.js"></script>
<script>
$(document).ready(function(){
//Examples of how to assign the Colorbox event to elements
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%", closeButton:false, escKey: false, overlayClose: false, opacity:0.30});
});
window.onload=function(){
$(".iframe").colorbox({href:"http://www.website.com/", open: true});
}
</script>
</head>
<body>
<p><a class='iframe' href="http://wikipedia.com"></a></p>
</body>
</html>
需要注意的是在身体上,我有:
< p>< a class='iframe' href="http://wikipedia.com">< /a>< /p>
如果我删除这条线,在iframe不开了。我是jquery的新手,所以对我来说这是没有意义的。我不想与“无意义”的东西一起工作。你们能否更好地向我解释如何使它以正确的方式工作?
请搜索一下jQuery选择......你会明白,颜色框附有类元素'上iframe' – JoDev