所以我有时会收到抱怨,说用户被带到网络钓鱼或者病毒传播网站而不点击任何东西。
我认为这是由一些恶意谷歌广告触发window.location和重定向造成的。有没有可能检测到这样的动作,这样我就可以记录广告源了吗?
P.S> srry只是为了澄清-> ,是否也可以检测用户在哪里使用,这样我们就可以区分恶意用户和非恶意用户了吗?
发布于 2017-01-05 14:40:00
您可以使用onbeforeunload快速发送有关重定向页面的信息。您可以决定用消息阻止重定向,从用户那里得到确认,或者只向后端发送一些关于发生了什么的数据。
window.onbeforeunload = function(event) {
// Send sync ajax call with event data
// Return a message to ask confirmation
return 'You are being redirected, please call the police'
}; 发布于 2017-01-05 14:40:10
要停止重定向,可以尝试使用onbeforeunload事件
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
window.onbeforeunload = function(e) {
var dialogText = 'Dialog text here';
e.returnValue = dialogText;
return dialogText;
};https://stackoverflow.com/questions/41487661
复制相似问题