假设我在脚本的最顶部有一些移动检查:
if (isMobile) {
window.location.href = '/m/' + window.location.pathname + window.location.search;
}
Run Code Online (Sandbox Code Playgroud)
而且我还在代码中(甚至在异步加载的其他模块中)有一些指标,这些指标被发送到我的指标服务器。
我的问题是:如何停止执行低于我的window.location更改的所有内容?或者更好的是,如何停止整个 javascript 引擎,使其不执行任何其他异步加载的模块?
我知道我可以通过许多不同的方式进行移动代理,但在此任务中,我的移动重定向必须在客户端运行,这是给定的。
if (isMobile) {
window.location.href = '/m/' + window.location.pathname + window.location.search;
return;
}
Run Code Online (Sandbox Code Playgroud)
很简单:return false...
if (isMobile) {
window.location.href = '/m/' + window.location.pathname + window.location.search;
return false;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9990 次 |
| 最近记录: |