一个提高转化率的脚本分享

此脚本的作用:用户退出页面的时候弹出一个对话框显示特价优惠等信息,用户确定后转到指定的URL。

此脚本的用法:将下面的代码放到<BODY>和</BODY>之间任意位置。

<script language=”javascript”>
(function() {
setTimeout(function() {
var __redirect_to = “http://www.url.com”; //更改此url为你的offer link
var _tags = [‘button’, ‘input’, ‘a’], _els, _i, _i2;
for(_i in _tags) {
_els = document.getElementsByTagName(_tags[_i]);
for(_i2 in _els) {
if((_tags[_i] == ‘input’ && _els[_i2].type != ‘button’ && _els[_i2].type != ‘submit’ && _els[_i2].type != ‘image’) || _els[_i2].target == ‘_blank’) continue;
_els[_i2].onclick = function() {window.onbeforeunload = function(){};}
}
}
window.onbeforeunload = function() {
setTimeout(function() {
window.onbeforeunload = function() {};
setTimeout(function() {
document.location.href = __redirect_to;
}, 500);
},5);
return ‘WAIT! Click STAY right now, I have something very special for you! ?’ //可定制消息
}
}, 500);
})();
</script>