user2214237
user2214237

Reputation: 63

delayed popup code

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>

Upvotes: 4

Views: 3210

Answers (3)

Nathalia Xavier
Nathalia Xavier

Reputation: 1039

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);

Upvotes: 0

BV2005
BV2005

Reputation: 157

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.

Upvotes: 1

pauljz
pauljz

Reputation: 10901

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>

Upvotes: 3

Related Questions