触发链接,但不要改变页面内容

Trigger link but don't change page content

本文关键字:改变 链接      更新时间:2023-09-26

是否有可能触发2个链接,但实际上只有一个被加载?我需要'登出'不加载,但不知何故被触发在后台(隐藏),所以他可以做到它的'登出'功能。

script type="text/javascript">
  window.location.href='logout.html';
  window.location.href='index.html';
</script>

使用ajax实现此功能。没有必要加载要执行的每个url。这就是现代网页的设计方式。谷歌更多关于ajax的信息。

你可以使用jquery ajax

$.ajax({
            type: "GET",
            url: redirecturl,
            async: true,
            success: function (response) {
                // called when the call executes successfully
            },
            error: function (response) {
                // called when the call cant execute successfully
            }
        });