Question:
I am trying to replace a twitter section on a page with javascript widget for Instagram.
Code:
$('#homepage-social-twitter').replaceWith("<a href='https://instawidget.net/v/user/pfaffmclaren' id='link-37c895c26e36ff'>@pfaffmclaren</a><"+"script src='https://instawidget.net/js/instawidget.js?u=37c895c26e36ff&width=260px'><"+"/script>");
Error:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
Chrome Error Details :
instawidget.js?u=37c895c26e36ff&width=260px&_=1535660742861:12 Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
Any Ideas on how to swap in a script to a web page dynamically as described above ?