首页 > 解决方案 > 隐藏 iframe 中显示的 Sharepoint 自定义列表的标题

问题描述

我有一个来自不同共享点站点(仍然是同一个域)的自定义列表,我想在没有标题的情况下在我的工作站点上显示(至少,摆脱功能区也很好)。我尝试了以下 4 种方法,但均未成功:

1)我什至无法通过将 ?isdlg=1 添加到我的网址末尾(即 ..allitems.aspx?isdlg=1)使其在正常页面上工作

2)因为我主要使用 SQL 而不是 HTML,所以我确信我可能搞砸了一些标签。

<div class="ms-dlgFrameContainer">
<iframe width="1400" height="600" id="DlgFramee" class="ms-dlgFrame" frameborder="0" src="myurl.aspx">
<html class="ms-dialog">
<head>
<style type="text/css">
.ms-dialog #titleAreaBox { display:none }
</style>`

3)隐藏iframe内的页面标题。

<script type="text/javascript">
document.getElementById("myiframe1").contentWindow.document.getElementById("titlerow").style.display = "none"; </script>`

4)最有希望的。当我添加

<iframe id="myiframe1" src="myurl" width="1000" height="450" frameborder="1"></iframe>
<style>
#titleAreaBox { display: none }
</style>

在与我的 iframe 相同的 CEWP 中,它删除了当前页面的标题区域,而不是 iframe 中的页面。这正是我想要的,除了我希望它对 iframe 内的页面执行此操作。

5)我也这样做了,即使只是试图改变标题颜色但没有注意到任何变化。我查找了正确的 webpart ID。

<style type="text/css">
#MSOZoneCell_WebPartWPQ2 .ms-WPHeader
{ background-color: pink; }
</style>

标签: javascriptcsssharepoint-2013

解决方案


你可以试试下面的 jQuery 脚本,我只是隐藏suiteBarTop在演示中。

<iframe id="myiframe" width="1400" height="600" id="DlgFramee" class="ms-dlgFrame" frameborder="0" src="/sites/tst/SitePages/Home.aspx"></iframe>

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#myiframe').load(function () {
                $(this).contents().find('#suiteBarTop').hide();
            });

        })        
    </script>

推荐阅读