如何建立一个链接,以便点击它来激发GET但不打开窗口(How to make a link so that clicking it fires a GET but do not open up a w

编程入门 行业动态 更新时间:2024-10-23 19:23:18
如何建立一个链接,以便点击它来激发GET但不打开窗口(How to make a link so that clicking it fires a GET but do not open up a window)

在我目前的双因素认证实施中,我通过链接向用户发送短信。 当链接被点击时,登录在用户机器上进行。

但是,在电话上,浏览器会打开一个空白页面(因为我目前正在从SMS服务器返回204来查看SMS中单击的链接。

我想要发生的是,当用户点击SMS中的链接时,broser根本不会打开。 它只需发送GET请求,用户就不必关闭手机上的浏览器窗口。

如果这是不可能的,是否有可能使打开的窗口立即自动关闭?

In my current implementetion of two-factor auth, I'm sending a SMS to the user with a link. When the link is clicked, the login proceedes on the users machine.

However, on the phone the browser will open up a empty page (since I'm currently returning 204 from the webserver for the link clicked in the SMS.

What I would like to happen is that when the user clicks the link in the SMS, the broser is not opened at all. It should just send the GET request, and the user will not have to close the browser window on his phone.

If that is not possible, is it possible to make the window that get's opened to autoclose imediately?

最满意答案

浏览器必须打开才能发出请求。 对此你无能为力。

但是,如果您控制来自Web服务器的内容,则可以尝试加载window.close() 。 实际上,您可能会被阻止,并且还应该有一个类似于“已登录,请关闭此窗口”的回退内容。 (你可以在点击按钮时调用window.close() 。)

The browser has to open to make the request. There's nothing you can do about this.

However, if you control the content from the web server, you can attempt a window.close() on-load. Realistically, you'll probably get blocked on this and should also have a fallback content that says something like, "logged in, please close this window". (You can probably call window.close() on a button click.)

更多推荐

SMS,用户,打开,link,电脑培训,计算机培训,IT培训"/> <meta name="description&qu

本文发布于:2023-07-05 09:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1035498.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:建立一个   但不   它来   窗口   链接

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!