dongshukou0240 2016-02-05 07:33
浏览 51
已采纳

删除函数的JQuery闪烁

Cannot find any answers on this particular scenario. CMS: Joomla I am use jquery on page that will be iframed to suppress the logo, menu items, etc that are contained in the central index.php header class.

the following code on the page to be iframed works okayish, but flickers (common problem right):

jQuery(function() {
            jQuery('.help').remove();
            jQuery('.dropdown').remove();
            jQuery("header").css("height", "    0px");
            jQuery("header").css("width", "0px");
            jQuery(":header").css({
                width: "0px",
                height: "0px"
            });

I have seen some solutions around document.write, which may work, however please note i cannot change the html in the index.php file, i have to find some way of only changing during or before page load (for the page load iframe) any help greatly appreciated!

Here is sample of the page that will be used for iframing (sometimes the classes do not load, i think this is due to the flickering/jolting of when the jquery kicks in : link

  • 写回答

1条回答 默认 最新

  • dongxian8272 2016-02-05 13:33
    关注

    If you can change the CSS code of your document, add the following style properties to it:

    .help,
    .dropdown {
        display: none;
    }
    header,
    :header {
        height: 0px;
        width: 0px;
    }
    

    If you cannot change the CSS of your page, use the following snippet to handle your problem (the files need to be included in the head, before the elements are loaded):

    <head>
    <script type="text/javascript" src="jquery.js"></script">
    <script type="text/javascript" src="file.js"></script>
    </head>
    

    file.js (not within $(document).ready()):

    $('<style type="text/css">.help, .dropdown { display: none; } header, :header { height: 0px; width: 0px; }</style>').appendTo('head');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器