本文介绍了延迟弹出代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在尝试为我的网站设置一个弹出式调查,该调查会在10秒钟后显示给访问者,但对编码的理解却很少. Surveymonkey为弹出窗口生成了以下代码,但是如何添加此延迟弹出窗口功能?
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>
推荐答案
您需要使用JavaScript在10秒钟的超时后将此脚本标签添加到页面中,而不是预先加载.这应该为您工作:
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>
这篇关于延迟弹出代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!