1

我参考了https://angular.io/guide/security#xss并尝试在我们的 Intranet sharePoint 网站上的网页上显示 PDF

这是模板:help.component.html:

<iframe class="e2e-iframe-trusted-src" width="640" height="390" [src]="trustedUrl" ></iframe>

和组件:help.component.ts

import { Component, OnInit } from '@angular/core';
import { SessionResetService } from '../../services/session-reset.service';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';

@Component({
  selector: 'app-help',
  templateUrl: './help.component.html',
  styleUrls: ['./help.component.scss']
})
export class HelpComponent implements OnInit {
    public trustedUrl: SafeUrl;
    public helpUrl: string;
    constructor(private _resetSession: SessionResetService,
        private sanitizer: DomSanitizer) {
        this.helpUrl = "https://website Url/Tool.pdf";
        this.trustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.helpUrl);
    }

    ngOnInit() {
        this._resetSession.CallResetSession();
  }
}

我尝试按照建议附加 &embedded=true: How to fix Refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin

但这也不起作用。请指导

4

0 回答 0