Dynamic iframe source with angular





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am trying to use payment system with Angular. In the payment gateway API, 3D Secure Page exposing as an html in json. I am trying to put this html in an iframe. The main problem is html is not shown. When I try to inspect element on browser, there are html code in the iframe but not shown. What is the reason of it? How can I solve this?



payment.component.ts:



this.applicationService.pay(this.card).subscribe((data: any) => {
this.modalContent = data.content;
}


payment.component.html



<iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>


3d secure content example:



<!doctype html>↵<html lang="en">↵<head>↵    <title>iyzico Mock 3D-Secure Processing Page</title>↵</head>↵<body>↵<form id="iyzico-3ds-form" action="https://sandbox-api.iyzipay.com/payment/mock/init3ds" method="post">↵    <input type="hidden" name="orderId" value="mock64-7127975743472898iyziord">↵    <input type="hidden" name="bin" value="405418">↵    <input type="hidden" name="successUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/success/37">↵    <input type="hidden" name="failureUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/failure/37">↵    <input type="hidden" name="confirmationUrl" value="https://sandbox-api.iyzipay.com/payment/mock/confirm3ds">↵    <input type="hidden" name="PaReq" value="66e28140-1079-4f29-81c6-0220c720620e">↵</form>↵<script type="text/javascript">↵    document.getElementById("iyzico-3ds-form").submit();↵</script>↵</body>↵</html>









share|improve this question

























  • If you want to use this then you must be getting the URL for iframe otherwise use div instead <iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>.

    – Sunil Singh
    Nov 16 '18 at 19:40













  • @SunilSingh I also tried that with div even it is not worked.

    – bl4cksta
    Nov 16 '18 at 19:43











  • I added the code in the answer.

    – Sunil Singh
    Nov 16 '18 at 19:49


















0















I am trying to use payment system with Angular. In the payment gateway API, 3D Secure Page exposing as an html in json. I am trying to put this html in an iframe. The main problem is html is not shown. When I try to inspect element on browser, there are html code in the iframe but not shown. What is the reason of it? How can I solve this?



payment.component.ts:



this.applicationService.pay(this.card).subscribe((data: any) => {
this.modalContent = data.content;
}


payment.component.html



<iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>


3d secure content example:



<!doctype html>↵<html lang="en">↵<head>↵    <title>iyzico Mock 3D-Secure Processing Page</title>↵</head>↵<body>↵<form id="iyzico-3ds-form" action="https://sandbox-api.iyzipay.com/payment/mock/init3ds" method="post">↵    <input type="hidden" name="orderId" value="mock64-7127975743472898iyziord">↵    <input type="hidden" name="bin" value="405418">↵    <input type="hidden" name="successUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/success/37">↵    <input type="hidden" name="failureUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/failure/37">↵    <input type="hidden" name="confirmationUrl" value="https://sandbox-api.iyzipay.com/payment/mock/confirm3ds">↵    <input type="hidden" name="PaReq" value="66e28140-1079-4f29-81c6-0220c720620e">↵</form>↵<script type="text/javascript">↵    document.getElementById("iyzico-3ds-form").submit();↵</script>↵</body>↵</html>









share|improve this question

























  • If you want to use this then you must be getting the URL for iframe otherwise use div instead <iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>.

    – Sunil Singh
    Nov 16 '18 at 19:40













  • @SunilSingh I also tried that with div even it is not worked.

    – bl4cksta
    Nov 16 '18 at 19:43











  • I added the code in the answer.

    – Sunil Singh
    Nov 16 '18 at 19:49














0












0








0








I am trying to use payment system with Angular. In the payment gateway API, 3D Secure Page exposing as an html in json. I am trying to put this html in an iframe. The main problem is html is not shown. When I try to inspect element on browser, there are html code in the iframe but not shown. What is the reason of it? How can I solve this?



payment.component.ts:



this.applicationService.pay(this.card).subscribe((data: any) => {
this.modalContent = data.content;
}


payment.component.html



<iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>


3d secure content example:



<!doctype html>↵<html lang="en">↵<head>↵    <title>iyzico Mock 3D-Secure Processing Page</title>↵</head>↵<body>↵<form id="iyzico-3ds-form" action="https://sandbox-api.iyzipay.com/payment/mock/init3ds" method="post">↵    <input type="hidden" name="orderId" value="mock64-7127975743472898iyziord">↵    <input type="hidden" name="bin" value="405418">↵    <input type="hidden" name="successUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/success/37">↵    <input type="hidden" name="failureUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/failure/37">↵    <input type="hidden" name="confirmationUrl" value="https://sandbox-api.iyzipay.com/payment/mock/confirm3ds">↵    <input type="hidden" name="PaReq" value="66e28140-1079-4f29-81c6-0220c720620e">↵</form>↵<script type="text/javascript">↵    document.getElementById("iyzico-3ds-form").submit();↵</script>↵</body>↵</html>









share|improve this question
















I am trying to use payment system with Angular. In the payment gateway API, 3D Secure Page exposing as an html in json. I am trying to put this html in an iframe. The main problem is html is not shown. When I try to inspect element on browser, there are html code in the iframe but not shown. What is the reason of it? How can I solve this?



payment.component.ts:



this.applicationService.pay(this.card).subscribe((data: any) => {
this.modalContent = data.content;
}


payment.component.html



<iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>


3d secure content example:



<!doctype html>↵<html lang="en">↵<head>↵    <title>iyzico Mock 3D-Secure Processing Page</title>↵</head>↵<body>↵<form id="iyzico-3ds-form" action="https://sandbox-api.iyzipay.com/payment/mock/init3ds" method="post">↵    <input type="hidden" name="orderId" value="mock64-7127975743472898iyziord">↵    <input type="hidden" name="bin" value="405418">↵    <input type="hidden" name="successUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/success/37">↵    <input type="hidden" name="failureUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/failure/37">↵    <input type="hidden" name="confirmationUrl" value="https://sandbox-api.iyzipay.com/payment/mock/confirm3ds">↵    <input type="hidden" name="PaReq" value="66e28140-1079-4f29-81c6-0220c720620e">↵</form>↵<script type="text/javascript">↵    document.getElementById("iyzico-3ds-form").submit();↵</script>↵</body>↵</html>






javascript angular






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 19:59







bl4cksta

















asked Nov 16 '18 at 19:02









bl4ckstabl4cksta

384417




384417













  • If you want to use this then you must be getting the URL for iframe otherwise use div instead <iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>.

    – Sunil Singh
    Nov 16 '18 at 19:40













  • @SunilSingh I also tried that with div even it is not worked.

    – bl4cksta
    Nov 16 '18 at 19:43











  • I added the code in the answer.

    – Sunil Singh
    Nov 16 '18 at 19:49



















  • If you want to use this then you must be getting the URL for iframe otherwise use div instead <iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>.

    – Sunil Singh
    Nov 16 '18 at 19:40













  • @SunilSingh I also tried that with div even it is not worked.

    – bl4cksta
    Nov 16 '18 at 19:43











  • I added the code in the answer.

    – Sunil Singh
    Nov 16 '18 at 19:49

















If you want to use this then you must be getting the URL for iframe otherwise use div instead <iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>.

– Sunil Singh
Nov 16 '18 at 19:40







If you want to use this then you must be getting the URL for iframe otherwise use div instead <iframe [innerHTML]="modalContent | sanitizeHtml" frameborder="0"></iframe>.

– Sunil Singh
Nov 16 '18 at 19:40















@SunilSingh I also tried that with div even it is not worked.

– bl4cksta
Nov 16 '18 at 19:43





@SunilSingh I also tried that with div even it is not worked.

– bl4cksta
Nov 16 '18 at 19:43













I added the code in the answer.

– Sunil Singh
Nov 16 '18 at 19:49





I added the code in the answer.

– Sunil Singh
Nov 16 '18 at 19:49












1 Answer
1






active

oldest

votes


















3














Use the following code snippet -



ts



@ViewChild('iframe') iframe: ElementRef;

this.applicationService.pay(this.card).subscribe((data: any) => {
this.setIframe(this.iframe);
}

private setIframe(iframe: ElementRef): void {
const win: Window = iframe.nativeElement.contentWindow;
const doc: Document = win.document;
doc.open();
doc.write(this.modalContent);
doc.close()
}


html



<iframe #iframe frameborder="1"></iframe>


Working copy is here - https://stackblitz.com/edit/angular-jc3qew






share|improve this answer


























  • this code sanitizing Html and script tags. I built pipe with bypassSecurityTrustHtml and still getting blank page.

    – bl4cksta
    Nov 16 '18 at 19:53











  • Can you share the html you are receiving.

    – Sunil Singh
    Nov 16 '18 at 19:54











  • updated question

    – bl4cksta
    Nov 16 '18 at 19:59











  • Updated the answer with code and demo link.

    – Sunil Singh
    Nov 16 '18 at 20:28











  • Yeah! That worked. Thanks a lot.

    – bl4cksta
    Nov 16 '18 at 20:39












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343911%2fdynamic-iframe-source-with-angular%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Use the following code snippet -



ts



@ViewChild('iframe') iframe: ElementRef;

this.applicationService.pay(this.card).subscribe((data: any) => {
this.setIframe(this.iframe);
}

private setIframe(iframe: ElementRef): void {
const win: Window = iframe.nativeElement.contentWindow;
const doc: Document = win.document;
doc.open();
doc.write(this.modalContent);
doc.close()
}


html



<iframe #iframe frameborder="1"></iframe>


Working copy is here - https://stackblitz.com/edit/angular-jc3qew






share|improve this answer


























  • this code sanitizing Html and script tags. I built pipe with bypassSecurityTrustHtml and still getting blank page.

    – bl4cksta
    Nov 16 '18 at 19:53











  • Can you share the html you are receiving.

    – Sunil Singh
    Nov 16 '18 at 19:54











  • updated question

    – bl4cksta
    Nov 16 '18 at 19:59











  • Updated the answer with code and demo link.

    – Sunil Singh
    Nov 16 '18 at 20:28











  • Yeah! That worked. Thanks a lot.

    – bl4cksta
    Nov 16 '18 at 20:39
















3














Use the following code snippet -



ts



@ViewChild('iframe') iframe: ElementRef;

this.applicationService.pay(this.card).subscribe((data: any) => {
this.setIframe(this.iframe);
}

private setIframe(iframe: ElementRef): void {
const win: Window = iframe.nativeElement.contentWindow;
const doc: Document = win.document;
doc.open();
doc.write(this.modalContent);
doc.close()
}


html



<iframe #iframe frameborder="1"></iframe>


Working copy is here - https://stackblitz.com/edit/angular-jc3qew






share|improve this answer


























  • this code sanitizing Html and script tags. I built pipe with bypassSecurityTrustHtml and still getting blank page.

    – bl4cksta
    Nov 16 '18 at 19:53











  • Can you share the html you are receiving.

    – Sunil Singh
    Nov 16 '18 at 19:54











  • updated question

    – bl4cksta
    Nov 16 '18 at 19:59











  • Updated the answer with code and demo link.

    – Sunil Singh
    Nov 16 '18 at 20:28











  • Yeah! That worked. Thanks a lot.

    – bl4cksta
    Nov 16 '18 at 20:39














3












3








3







Use the following code snippet -



ts



@ViewChild('iframe') iframe: ElementRef;

this.applicationService.pay(this.card).subscribe((data: any) => {
this.setIframe(this.iframe);
}

private setIframe(iframe: ElementRef): void {
const win: Window = iframe.nativeElement.contentWindow;
const doc: Document = win.document;
doc.open();
doc.write(this.modalContent);
doc.close()
}


html



<iframe #iframe frameborder="1"></iframe>


Working copy is here - https://stackblitz.com/edit/angular-jc3qew






share|improve this answer















Use the following code snippet -



ts



@ViewChild('iframe') iframe: ElementRef;

this.applicationService.pay(this.card).subscribe((data: any) => {
this.setIframe(this.iframe);
}

private setIframe(iframe: ElementRef): void {
const win: Window = iframe.nativeElement.contentWindow;
const doc: Document = win.document;
doc.open();
doc.write(this.modalContent);
doc.close()
}


html



<iframe #iframe frameborder="1"></iframe>


Working copy is here - https://stackblitz.com/edit/angular-jc3qew







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 16 '18 at 20:27

























answered Nov 16 '18 at 19:48









Sunil SinghSunil Singh

6,5272628




6,5272628













  • this code sanitizing Html and script tags. I built pipe with bypassSecurityTrustHtml and still getting blank page.

    – bl4cksta
    Nov 16 '18 at 19:53











  • Can you share the html you are receiving.

    – Sunil Singh
    Nov 16 '18 at 19:54











  • updated question

    – bl4cksta
    Nov 16 '18 at 19:59











  • Updated the answer with code and demo link.

    – Sunil Singh
    Nov 16 '18 at 20:28











  • Yeah! That worked. Thanks a lot.

    – bl4cksta
    Nov 16 '18 at 20:39



















  • this code sanitizing Html and script tags. I built pipe with bypassSecurityTrustHtml and still getting blank page.

    – bl4cksta
    Nov 16 '18 at 19:53











  • Can you share the html you are receiving.

    – Sunil Singh
    Nov 16 '18 at 19:54











  • updated question

    – bl4cksta
    Nov 16 '18 at 19:59











  • Updated the answer with code and demo link.

    – Sunil Singh
    Nov 16 '18 at 20:28











  • Yeah! That worked. Thanks a lot.

    – bl4cksta
    Nov 16 '18 at 20:39

















this code sanitizing Html and script tags. I built pipe with bypassSecurityTrustHtml and still getting blank page.

– bl4cksta
Nov 16 '18 at 19:53





this code sanitizing Html and script tags. I built pipe with bypassSecurityTrustHtml and still getting blank page.

– bl4cksta
Nov 16 '18 at 19:53













Can you share the html you are receiving.

– Sunil Singh
Nov 16 '18 at 19:54





Can you share the html you are receiving.

– Sunil Singh
Nov 16 '18 at 19:54













updated question

– bl4cksta
Nov 16 '18 at 19:59





updated question

– bl4cksta
Nov 16 '18 at 19:59













Updated the answer with code and demo link.

– Sunil Singh
Nov 16 '18 at 20:28





Updated the answer with code and demo link.

– Sunil Singh
Nov 16 '18 at 20:28













Yeah! That worked. Thanks a lot.

– bl4cksta
Nov 16 '18 at 20:39





Yeah! That worked. Thanks a lot.

– bl4cksta
Nov 16 '18 at 20:39




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343911%2fdynamic-iframe-source-with-angular%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values