日期:2014-05-16  浏览次数:20340 次

jquery插件boxy.js,父窗口函数关闭弹出层问题
点击"弹出层";就弹出一个层,这时,还可以点击父窗口的页面..
现在我要点击"关闭我"来关闭弹出层,请问这个函数怎么写?
等着熟悉BOXY的牛人回答..
现在这个函数可以解决,但是点击了"关闭我",再点击"弹出层",就不再弹出层了.
案例中有这么一句:Boxy.get(this).hide();但是这传递的是this自身对象..
在父窗口页面怎么写函数来调用这个方法呢?
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" href="boxy.css" type="text/css" />
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript" src="jquery.boxy.js"></script>
<script type="text/javascript">
$(function(){
     $(".boxy").boxy();
});
function closeBoxy()
{
    $('.boxy-wrapper').hide();
}

</script>
</head>

<body>
<a href="#foobar" title="弹出层" class="boxy">弹出层</a></p>
<div id="foobar" style="padding:15px; display:none; background-color:#cad5eb; font-size:2em; color:#000000; font-weight:bold;"><div style="width:600px;height:600px"><input name="aaa" />这是一段ID为foobar的div标签内的文字</div></div>
<a href="javascript:void(0)" onclick="closeBoxy()">关闭我</a>            
</body>
</html>



------解决方案--------------------
HTML code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" href="boxy.css" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.boxy.js"></script>
<script type="text/javascript">
var box;
$(function(){
     box = new Boxy($("#foobar"), {show:false});
});
function openBoxy(){
    box.show();
}
function closeBoxy()
{
    box.hide();
}

</script>
</head>

<body>
<a href="javascript:openBoxy();void(0);" title="弹出层">弹出层</a>
<a href="javascript:closeBoxy();void(0);">关闭我</a>
<div id="foobar" style="padding:15px; display:none; background-color:#cad5eb; font-size:2em; color:#000000; font-weight:bold;">
    <div style="width:600px;height:300px">
        <input name="aaa" />这是一段ID为foobar的div标签内的文字
    </div>
</div>
</body>
</html>