【问题标题】:post data to a site and load it in another site in iframe (angular and c#)将数据发布到站点并将其加载到 iframe 中的另一个站点(角度和 c#)
【发布时间】:2020-01-24 12:59:41
【问题描述】:

我有两个不同的 Angular 5 项目(siteone 和 sitetwo)。 sitetwo 是仪表板,我必须通过单击选项卡“仪表板”将其加载到 siteone 的 iframe 中。 但是,具有某些输入的表单应首先提交到 sitetwo url,然后将其加载到 iframe 中。

我的 iframe 组件看起来像 myiframe.html

<div *ngIf="strurl">
    <object data="">
        <embed height="1200"  width="100%" [src]="strurl">
    </object> 
</div>

strurl 来自服务调用,我使用 domsanitizer 来避免 safeurl 问题,我必须在 iframe 中使用相同的 url。我使用 router.navigate 在单击选项卡时加载相应的组件。

请就如何将数据发布到site2然后将其加载到site1的iframe中提出一个解决方案。

(请注意:在我们采用插件架构以供跨应用程序使用之前,这是一个短期解决方案)

【问题讨论】:

    标签: javascript c# angular iframe


    【解决方案1】:

    尝试使用安全管道:

    import { Pipe, PipeTransform } from '@angular/core';
    import { DomSanitizer} from '@angular/platform-browser';
    
    @Pipe({ name: 'safe' })
    export class SafePipe implements PipeTransform {
       constructor(private sanitizer: DomSanitizer) {}
       transform(url) {
         return this.sanitizer.bypassSecurityTrustResourceUrl(url);
       }
    } 
    

    HTML 代码:

    <embed height="1200"  width="100%" [src]="strurl | safe"">
    

    【讨论】:

    • 对不起,如果我的问题不是很清楚。生病更新我的问题陈述。我的问题是如何将数据从 site1 发布到 site2 并将其加载到 iframe 中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-24
    • 1970-01-01
    • 2017-03-29
    • 2014-11-22
    相关资源
    最近更新 更多