How to open html code in iframe or new page?

Gowri S
Tera Expert

From UI action, we have outbound API call to external system as response they are sending html code and it has to be opened in iframe or new page, it will be external page not ServiceNow page.

 

I am receiving the HTML code, now I am not sure how to open it in new page or iframe. Kindly let me know if this is possible.

 

Thanks Gowri

1 ACCEPTED SOLUTION

Gowri S
Tera Expert

The solution to open in new page using window.open with form hidden inputs as similar to below Reference

 javascript - Window.open and pass parameters by post method - Stack Overflow

View solution in original post

16 REPLIES 16

@Gowri S 

 

Can you paste the content here instead of screenshot,

@Prince Arora ,

 

Please find the below html code, we will receive similar to this in API response.

 

"<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"/><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"><link rel=\"icon\" href=\"./favicon.ico\"/><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"/><meta name=\"theme-color\" content=\"#000000\"/><meta name=\"description\" content=\"Web site created using create-react-app\"/><link rel=\"apple-touch-icon\" href=\"logo192.png\"/><link rel=\"manifest\" href=\"./manifest.json\"/><title>Test</title><link href=\"./static/css/2.********.chunk.css\" rel=\"stylesheet\"><link href=\"./static/css/main.********.chunk.css\" rel=\"stylesheet\"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id=\"root\"></div><script src=\"./static/js/runtime-main.********.js\"></script><script src=\"./static/js/2.********.chunk.js\"></script><script src=\"./static/js/main.********.chunk.js\"></script></body></html>"

 

Please be informed that, this has to open the external website to book appointments, so the response will differ each time.

Gowri S
Tera Expert

Kindly let me know if there is way to implement it.

@Gowri S 

 

Actually this is a XML response from the API call, you need to parse the response and make a proper html code from that then render it using GLideModal

 

hi @Prince Arora,

 

As the html code has the js, css files which does not exist at our end, it is showing blank page. The html code has to rendered in the browser, during rendering those files could be access directly from external system. 

 

Kindly let me know if there is a way to open the html code in the browser directly as new page from UI action?