[英]How to integrate survey monkey website embed in angular
I have survey monkey account, which have multiple surveys, i want to add this website embed survey in my angular website which have bootstrap and jquery already added.我有调查猴子帐户,其中有多个调查,我想将此网站嵌入调查添加到我已经添加了引导程序和 jquery 的角度网站中。 I tried with direct script in html component but its not working.我尝试在 html 组件中使用直接脚本,但它不起作用。
<script>(function(t,e,s,n){var o,a,c;t.SMCX=t.SMCX||[],e.getElementById(n)||(o=e.getElementsByTagName(s),a=o[o.length-1],c=e.createElement(s),c.type="text/javascript",c.async=!0,c.id=n,c.src=["https:"===location.protocol?"https://":"http://","widget.surveymonkey.com/collect/website/js/kjhasdkhkkjhk324234hkjhaksdkadhk.js"].join(""),a.parentNode.insertBefore(c,a))})(window,document,"script","smcx-sdk");</script>
Also i want to set this "widget.surveymonkey.com/collect/website/js/kjhasdkhkkjhk324234hkjhaksdkadhk.js" url dynamically added.我也想动态添加这个“widget.surveymonkey.com/collect/website/js/kjhasdkhkkjhk324234hkjhaksdkadhk.js”网址。
Like this像这样
var url = "widget.surveymonkey.com/collect/website/js/kjhasdkhkkjhk324234hkjhaksdkadhk.js";
<script>(function(t,e,s,n){var o,a,c;t.SMCX=t.SMCX||[],e.getElementById(n)||(o=e.getElementsByTagName(s),a=o[o.length-1],c=e.createElement(s),c.type="text/javascript",c.async=!0,c.id=n,c.src=["https:"===location.protocol?"https://":url].join(""),a.parentNode.insertBefore(c,a))})(window,document,"script","smcx-sdk");</script>
Thank you in advance.先感谢您。
I faced the same issue with the script and this is how I managed to integrate the survey monkey embed script in my angular application.我在脚本中遇到了同样的问题,这就是我如何设法将调查猴子嵌入脚本集成到我的 angular 应用程序中。
In component.html在 component.html
<div id="smcx-sdk"> </div>
In component.ts在 component.ts
ngAfterViewInit(){
var script = document.createElement('script');
script.src = "http://<replace your widget url>";
document.getElementById("smcx-sdk").appendChild(script);
}
Make sure the element's id is "smcx-sdk".确保元素的 id 是“smcx-sdk”。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.