delayed popup code

百般思念 提交于 2019-12-12 16:18:01

问题


I'm currently trying to set up a pop-up survey for my website that appears to visitors after 10 seconds, but only have a remedial understanding of coding. Surveymonkey generated the following code for the pop-up, but how would I add in this delayed pop-up feature?

<script src="http://www.surveymonkey.com/jsPop.aspx?sm=WVuy7oI7MerxwqmaCFF23g_3d_3d"> </script>

回答1:


You'll need to use JavaScript to add this script tag to the page after a 10 second timeout, rather than loading it up front. This should work for you:

<script>
    setTimeout(function() {
        var head = document.getElementsByTagName('head')[0];
        var script = document.createElement('script');
        script.src = 'http://www.surveymonkey.com/jsPop.aspx?sm=WVuy7oI7MerxwqmaCFF23g_3d_3d';
        head.appendChild(script);
    }, 10000);
</script>



回答2:


I did mine a little differently since I am using survey monkeys "Collect Responses" installation code for the popup survey, so I figured I would post my response in the hopes it would help someone else.

var myfunc = function(e,t,o,n){}();
window.setTimeout(myfunc, 30000);

I set my timeout for 30 seconds.




回答3:


I also used the "Collect Responses" install code but the code suggested bt BV2005 didn't work for me. I had to do it like this:

function OpenSurvey(e,t,n,o){};
window.setTimeout(function(){ OpenSurvey(window,document,"script","smx-sk"); }, 30000);


来源:https://stackoverflow.com/questions/15652104/delayed-popup-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!