如果用户粘贴了网址,则阻止导航 [英] Prevent navigation if url is pasted by user

查看:78
本文介绍了如果用户粘贴了网址,则阻止导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的Web应用程序中,我要求用户必须通过页面上的链接或按钮进行导航.这意味着用户不仅可以复制并粘贴任何URL来打开页面.

有什么办法可以做到吗?

在此先感谢您.

Hello all,

In my web application I have a requirement in which user must navigate thru link or buttons available on page. That means users can''t just copy and paste any url an open the page.

Is there any way I can do this?

Thanks in advance.

推荐答案

在您要保护的页面中,检查是否存在http referer标头并将其设置为包含按钮的页面的URL. /关联.如果不是,那么您可以显示错误页面或什么都不显示...(或者,如果您真的很邪恶,请重定向到讨厌的URL;))
这并不是万无一失的,因为用户可以欺骗引荐来源,但这就像您前门上的锁-它将诚实的人拒之门外.

彼得
In the pages you wish to protect, check that the http referer header is present and set to the URL of the page containing your button/link. If it''s not, then you can show an error page or nothing... (or if you''re really evil, redirect to a nasty URL ;) )
This is not foolproof, since the user can spoof the referer, but it''s like the lock on your front door - it will keep the honest people out.

Peter


这篇关于如果用户粘贴了网址,则阻止导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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