我有像下面这样的父页面parent.html来调用colorbox:
<script src="colorbox/jquery.min.js"></script>
<script src="colorbox/jquery.colorbox.js"></script>
<script>
$(document).ready(function(){
$(".example7").colorbox({
width:"60%",
height:"40%",
iframe:true
});
//How I can get Parameters from ColorBox when ColorBox closed
</script>
<body>
<p><a class='example7' href="demo_01.html">Click here to open Colorbox</a></p>
</body>在demo_01.html上,我有两张图片
<html>
<script type="text/javascript">
function onChooseAndClose(val){
//how to setup to sent paramters (ID of image was chosen) to parent page before close colorbox
......
//close this Colorbox
parent.$.fn.colorbox.close()
}
</script>
<body>
<img src="imamges/img1.png" id="idImg1" onclick="javascript:onChooseAndClose('idImg1');" />
<img src="imamges/img2.png" id="idImg2" onclick="javascript:onChooseAndClose('idImg2');" />
</body>
</html>在parent.html中,当ColorBox关闭时如何从ColorBox获取参数
谢谢。
发布于 2011-05-06 16:52:17
您可以使用自己的函数覆盖Colorbox的close函数。
var originalClose = $.colorbox.close;
$.colorbox.close = function(){
var response;
if($('#cboxLoadedContent').find('form').length > 0){
response = confirm('Do you want to close this window?');
if(!response){
return; // Do nothing.
}
}
originalClose();
}; 这里我们得到了原始的close方法。然后我们重写该方法来编写脚本,最后调用原始Close方法。
https://stackoverflow.com/questions/5216203
复制相似问题