我正在尝试从 iframe中关闭FancyBoxparent.$
,但始终是undefined
. 这是我的 iframe JavaScript:
<script type='text/javascript'
src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'>
</script>
<script type="text/javascript">
jQuery(document).ready(function($){
(function($) {
$.fn.closeFancyBox = function() {
$(this).click(function() {
parent.$.fancybox.close();
});
};
})(jQuery);
$('#cancel').closeFancyBox();
});
});
</script>
换成作品就好了parent.$.fancybox.close();
。alert('clicked');
我不明白为什么parent.$
iframeundefined
在同一个域中。
我正在使用带有 FancyBox for Wordpress 插件的 WordPress 2.9.1。
- 主页:
//server.local/web/test/index.php
- iframe 页面:
//server.local/web/test/wp-content/plugins/wp-test/test.htm
这些url中的第一个是主页,第二个是iframe页面;server.local
是我的家庭测试服务器。
有任何想法吗?如果有帮助,我可以粘贴整个源代码。