使用 js 调整 iframe 的大小在 https 时停止工作

Resizing of iframe with js stops working when https

本文关键字:https 停止工作 js 调整 iframe 使用      更新时间:2023-09-26

我想做的是调整一个花哨的iframe的大小,我认为我通过调用以下功能成功了:

parent.jQuery('#fancybox-inner').css({'height': '450px'});
parent.jQuery('#fancybox-wrap').css({'height': '550px'});

但是,当将其部署到我在https中工作的阶段区域时,此解决方案不起作用,我想这与https部分有关。我试图用谷歌搜索这个,但我没有找到任何合适的解决方案。可以帮帮我,记住我是JS新手。

法典:

jQuery().ready(function() {
    jQuery('#no_user').click(function () { 
        if (jQuery(".temp_expand").css("display") == "none") {
            jQuery(".temp_expand").slideDown();
                parent.jQuery('#fancybox-inner').css({'height': '450px'});
                parent.jQuery('#fancybox-wrap').css({'height': '550px'});
            }
            else {
                jQuery(".temp_expand").slideUp();
                jQuery(".temp_expand").css("display", "none");                    
                parent.jQuery('#fancybox-inner').css({'height': '850px'});
                parent.jQuery('#fancybox-wrap').css({'height': '950px'});
            }
            }).toggle(function() {
                jQuery('#temp_no_user').text("#{messages['login']}");
            }, function() {
                jQuery('#temp_no_user').text("#{messages['register']}");
            });           
        });

编辑开始

我收到一个JS错误:

Error: Permission denied to access property 'jQuery'
Source File: https://stage.temp.se/login/login
Line: 185

编辑结束

听起来你有页面是https,框架源是http - 反之亦然。如果是这种情况,这可能会有所帮助:

通过 Javascript 从 https 页面更新 http 父页面

允许 HTTP iFrame 在 HTTPS 父帧上调用 JavaScript