重定向页面并防止页面的其余部分加载和脚本执行 [英] Redirect the page and prevent the rest of the page from loading and script from execution

查看:115
本文介绍了重定向页面并防止页面的其余部分加载和脚本执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在开始加载时重定向页面(例如加载页面的头部),并且一旦重定向,就会阻止/停止页面内容的其余部分加载以及执行的其余脚本。

I need to redirect page when it starts loading (e.g. the head part of the page loaded) and once it is redirected prevent/stop the rest of the page content from loading and the rest of the script from execution.

如果我在打开HEAD标签并将页面重定向到另一个页面后的第一行放置此代码(window.location =/ other-page-url;),它是否会停止执行下一个脚本?
我想确定如果有,比方说,在第二行调用一些计数器脚本,在重定向之后,它将不会执行。

If I place this code (window.location = "/other-page-url";) at the first line after opening HEAD tag and redirect page to another one, will it stop execution of next going scripts? I want to be sure that if there are, let's say, some counter script called on the second line, just after redirection, it will not execute.

可能是JavaScript有一些停止页面加载/渲染的方法吗?

May be JavaScript has some method which stops page loading/rendering?

推荐答案

将用户重定向到另一个页面后,当前页面将立即停止执行。

Once you have redirected the user to a different page, the current page will stop execution immediately.

这篇关于重定向页面并防止页面的其余部分加载和脚本执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆