当用户访问书签页面时更改书签的 URL
我正在尝试更改书签的 URL,以便当用户为页面添加书签时,它实际上为用户必须首先通过的不同 URL 添加书签。 javascript 或其他语言可以实现这一点吗?
I'm trying to change the URL of a bookmark so that when the user bookmarks a page, it actually bookmarks a different URL that the user must pass through first. Is that possible with javascript or any other languages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不。书签是在浏览器(HTTP 客户端)中实现的功能。它将为用户命令浏览器执行的操作添加书签。在所有浏览器中,这几乎总是显示在地址字段中的 URL。
因此,通常不可能在浏览器中操纵书签的存储。
然而,根据您尝试实现的目标,您的应用程序可能提供仅在一小部分时间内有效的 URL。如果已添加书签并且已经过了该时间,则您的应用程序确实知道这是一个较旧的 URL,因此可以假定是已添加书签的 URL。然后,您可以让您的应用程序对此做出反应,提供用户必须通过的附加页面。
这也可以通过某种会话来完成,并与引用者检查相结合。
No. Bookmarking is a functionality implemented in the browser, the HTTP client. It will bookmark what the user commands the browser to do. This almost always in all browsers is the URL displayed in the address field.
So it is normally not possible within a browser to manipulate the storage of the bookmark.
However depending on what you try to achieve, your application can provide URLs that only work for a fraction of time. If bookmarked and that amount of time has passed, your application does know that this is an older, hence assumable a bookmarked URL. You can then make your application react to that, offering an additional page a user must pass through.
This can be done with some sort of session as well, and combined with referrer checking.
不,您无法更改用户的书签,但您可以通过执行正确的 301 重定向来确保用户到达新页面。
No, you can't change a user's bookmark, but you can make sure the user gets to the new page by doing a proper 301 redirect.
那么你可以尝试劫持
Ctrl+D
命令来添加书签。任何比这更远的东西都是不可行的,因为书签通常是由浏览器而不是网站处理的。
Well you can try to hijack the
Ctrl+D
command to bookmark.Anything farther than that is not really feasible since bookmarking is usually handled by the browser and not the website.