SharePoint 2013 Dialog 此内容不能显示在一个框架中

本文介绍了在SharePoint 2013中遇到'此内容不能显示在一个框架中'错误时的解决方法。针对由SP.UI.Dialog引发的问题,不同于Iframe的解决方案,文章提供了一种特定的处理方式,包括在Internet Explorer的安全设置中添加受信任的站点,如*microsoftonline.com和*sharepoint.com。同时,也提到了其他可能的参考资料,但并非所有方法都确保有效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SharePoint 2013 Dialog 此内容不能显示在一个框架中

此处内容是引用了SP.UI.Dialog。

与Iframe 引起的内容处理方法完全不一致。用了一天的时间,也没有修改完成。后来发现如下修改可以搞定。


此内容不能显示在一个框架中

为了帮助保护在此网站中输入的信息的安全,此内容的发布者不允许在框架中显示该信息。


你可以尝试以下操作:


在新窗口中打开此内容



使用IE错误抓图如下,如果使用chrome则是空白页面。

如果是Iframe引起的请参考霖雨的博客:

http://www.cnblogs.com/jianyus/p/3385514.html

http://www.cnblogs.com/jianyus/p/3808210.html


如果是Dialog 引起的,使用上述方法无效。

首先,做如下设置:

  1. 在 Internet Explorer 上 工具 菜单中,单击 Internet 选项.
  2. 单击安全 选项卡上,单击 受信任的站点区域,然后单击 站点.
  3. 请确保在中列出的以下各项 网站 列表:
    • *.microsoftonline.com
    • *.sharepoint.com
然后使用chrome跟踪代码,发现如下错误。


看到这里问题很明确了吧。

Mixed Content: The page at 'https://xxx.xxx.com.cn/itc/SitePages/CreateReport.aspx' was loaded over HTTPS, but requested an insecure resource 'http://sharepoint/_layouts/15/AD/adPicker.aspx?ou=gdUsers&IsDlg=1'. This request has been blocked; the content must be served over HTTPS.

这里你内层和外层修改成一致即可。



也可以参考这个,我使用这个方法没有成功。

https://msdn.microsoft.com/ZH-CN/library/office/fp179921(v=office.15).aspx




### WPF 中 Dialog 对话框居中显示的设置方法及问题排查 在 WPF 中,对话框默认可能会自动居中显示,这通常与父窗口的布局、对话框的启动位置以及具体的属性设置有关。以下是关于如何实现对话框居中显示的详细说明以及可能的问题排查步骤。 --- #### 1. **设置 `WindowStartupLocation` 属性** 在 WPF 中,可以通过设置 `WindowStartupLocation` 属性来控制对话框的初始位置。将其设置为 `CenterOwner` 或 `CenterScreen` 可以实现居中效果。 ```xml <Window x:Class="WpfApp.DialogWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Dialog Window" Height="300" Width="400" WindowStartupLocation="CenterOwner"> </Window> ``` 如果需要对话框相对于屏幕居中,则可以将 `WindowStartupLocation` 设置为 `CenterScreen`[^2]。 --- #### 2. **确保父窗口正确传递给对话框** 当使用 `ShowDialog()` 方法显示对话框时,必须确保将父窗口作为参数传递给对话框,以便对话框能够正确计算其相对于父窗口的位置。 ```csharp var dialog = new DialogWindow(); dialog.Owner = Application.Current.MainWindow; // 设置父窗口 dialog.ShowDialog(); ``` --- #### 3. **动态调整对话框位置** 如果父窗口或屏幕大小发生变化,可以通过监听 `SizeChanged` 或 `LocationChanged` 事件动态调整对话框的位置。 ```csharp private void AdjustDialogPosition(Window dialog, Window owner) { if (owner != null && dialog != null) { dialog.Left = owner.Left + (owner.ActualWidth - dialog.ActualWidth) / 2; dialog.Top = owner.Top + (owner.ActualHeight - dialog.ActualHeight) / 2; } } private void MainWindow_SizeChanged(object sender, SizeChangedEventArgs e) { var dialog = Application.Current.Windows.OfType<Window>().FirstOrDefault(w => w.IsActive && w != this); if (dialog != null) { AdjustDialogPosition(dialog, this); } } ``` --- #### 4. **Prism 框架中的对话框居中设置** 在使用 Prism 框架时,可以通过自定义 `IDialogWindow` 的实现来确保对话框始终居中显示。例如,在 `IDialogService` 的 `ShowDialog` 方法中,设置 `WindowStartupLocation` 为 `CenterOwner`[^3]。 ```csharp public class CustomDialogWindow : IDialogWindow { public void Show() { this.WindowStartupLocation = WindowStartupLocation.CenterOwner; base.Show(); } } ``` --- #### 5. **排查常见问题** - **问题 1:对话框未居中** 确保 `WindowStartupLocation` 被正确设置,并且父窗口通过 `Owner` 属性传递给对话框[^2]。 - **问题 2:动态调整失败** 如果父窗口大小或位置发生变化后,对话框未能正确调整,检查是否监听了 `SizeChanged` 和 `LocationChanged` 事件。 - **问题 3:Prism 框架下未居中** 确保自定义的 `IDialogWindow` 实现中设置了 `WindowStartupLocation` 为 `CenterOwner`[^3]。 --- #### 示例代码 以下是一个完整的示例,展示如何在 WPF 中实现对话框的居中显示: ```xml <Window x:Class="WpfApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="450" Width="800"> <Grid> <Button Content="Open Dialog" HorizontalAlignment="Center" VerticalAlignment="Center" Click="OpenDialog_Click"/> </Grid> </Window> ``` ```csharp private void OpenDialog_Click(object sender, RoutedEventArgs e) { var dialog = new DialogWindow(); dialog.Owner = this; // 设置父窗口 dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; dialog.ShowDialog(); } ``` --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值