有没有办法在IFRAME src页面中隐藏元素? [英] is there a way hide elements in IFRAME src page?

查看:632
本文介绍了有没有办法在IFRAME src页面中隐藏元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的代码。我喜欢在我的IFRAMe中隐藏一些DIV。所以我的index.html页面看起来像这样,所以整个想法隐藏了Calendar.aspx页面的顶部和左侧面板。



任何想法我的错在哪里代码或应该怎么做?

 < script src =https://code.jquery.com/jquery- 1.11.1.min.js>< /<脚本> 

< script type =text / javascript>
$(document).ready(function(){
$(#leftpanel)。hide();
$(#toppanel)。hide
}) ;
();
< / script>
< iframe height =800pxwidth =800pxsrc =https://domain/Calendar/Calendar%20Color%20Overview.aspx>
< / iframe>


解决方案

您可以试试这个:

$ b $($#
$ b $ $ $ $'code $ $'''iframeID')。load(function(){
$('#iframeID')。contents()。find '#leftpanel')。hide();
$('#iframeID')。contents()。find('#toppanel')。hide();
});

或者:

  $(document).ready(function(){
$('#iframeID')。contents()。find('#leftpanel')。hide();
$( '#iframeID')。contents()。find('#toppanel')。hide();
});

如果您想使用不同的域名,则无法使用此方法。


I have a very simple code. I like to hide some DIV's in my IFRAMe. So my index.html page looks like this, so the whole idea is hide the top and the leftpanel of from the Calendar.aspx page.

any idea what's wrong with my code or how should I do this?

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></<script>

<script type="text/javascript">
$( document ).ready(function() {
$("#leftpanel").hide();
$("#toppanel").hide
});
();
</script>
<iframe height="800px" width="800px"  src="https://domain/Calendar/Calendar%20Color%20Overview.aspx" >
</iframe>

解决方案

You can try this:

$('#iframeID').load(function(){
    $('#iframeID').contents().find('#leftpanel').hide();
    $('#iframeID').contents().find('#toppanel').hide();
});

Or:

$(document).ready(function(){
    $('#iframeID').contents().find('#leftpanel').hide();
    $('#iframeID').contents().find('#toppanel').hide();
});

This method is not possible if you want to work with different domains.

这篇关于有没有办法在IFRAME src页面中隐藏元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆