Binding string response(with HTMLTags) to iframe

2019-08-31 04:14发布

I make a ajax call to rest endpoint which returns HTML tags as a string response. Now I need to bind this to iframe.

Here data has html tags like

var data="<html><head><title>iFram</title></head><body>hi</body></html>"

I have tried document.getElementById('iframeid').src=data

also I have tried

$('#iframeid').contents().find("html").append(data);

thanks

1条回答
倾城 Initia
2楼-- · 2019-08-31 04:43

finally we have got the solution with iframe attribute "srcdoc" which we used like document.getElementById('iframeid').srcdoc=data;

查看更多
登录 后发表回答