如何使用 javascript 或 jquery 禁用 url 地址栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16351273/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 04:17:48  来源:igfitidea点击:

How to disable the url address bar using javascript or jquery

javascriptjquery

提问by Imesh Chandrasiri

I've got a spring mvc framework and I want to disable the url address bar when the page loads! (It's not a public web application) How can I achieve this using javascript or jquery.

我有一个 spring mvc 框架,我想在页面加载时禁用 url 地址栏!(它不是公共 Web 应用程序)我如何使用 javascript 或 jquery 实现这一点。

Update :

更新 :

Guys, If I can make the url bar read only that would be okay too!

伙计们,如果我能让 url 栏只读,那也没关系!

回答by TGH

One potential workaround is to create a simple WPF app that hosts a web browser control that fills up the entire form. The web browser control does not have the url address bar,so you can simulate what you're describing using this approach. Might work since you said it's an internal application.

一种可能的解决方法是创建一个简单的 WPF 应用程序,该应用程序托管一个填充整个表单的 Web 浏览器控件。Web 浏览器控件没有 url 地址栏,因此您可以使用这种方法模拟您所描述的内容。可能有用,因为你说它是一个内部应用程序。

Note: The browser control will behave like IE

注意:浏览器控件的行为类似于 IE

回答by Ken Herbert

You cannot hide the address bar in your browser programmatically.

您无法以编程方式隐藏浏览器中的地址栏。

You can hide the address bar in browser windows opened by your javascript code, although I think some browsers are even overriding this now too.

您可以在由您的 javascript 代码打开的浏览器窗口中隐藏地址栏,尽管我认为某些浏览器现在甚至也覆盖了它。

回答by hsuk

I am afraid this is mission Impossible. You can't hide something that is directing you. The link on webpages are all visible. The concept to hide url is to making them non understandable. Encrypt the certain portion of the url like id, slug ...

恐怕这是不可能完成的任务。你不能隐藏正在引导你的东西。网页上的链接都是可见的。隐藏 url 的概念是使它们无法理解。加密 url 的特定部分,如 id、slug ...

回答by Milan

  1. You can make location bar readonly only if you are using window.open.
  2. In case of IE, we can change the setting of browser for this. But this may not be good idea.
  1. 仅当您使用 window.open 时,您才能将位置栏设为只读。
  2. 如果是 IE,我们可以为此更改浏览器的设置。但这可能不是个好主意。

so for just disabling location bar by using window.open, the code is as follows:

所以只是使用window.open禁用位置栏,代码如下:

subwin = window.open(url,"dummyname",'width=635px,resizable=no, height=535px, menubar=no, toolbar=no, location=no, scrollbars=no'); 

In the example above, location=no disables the location bar. You can change the value of size,scrollbars, menubar etc. as your choice.

在上面的示例中, location=no 禁用位置栏。您可以根据自己的选择更改大小、滚动条、菜单栏等的值。

Thank you.

谢谢你。