JavaScript 问题工具栏=否

发布于 2024-08-17 22:07:16 字数 220 浏览 1 评论 0原文

我有一个简单的登录页面。当用户通过验证后,窗口将导航到新页面。 javascript 是 window.open('http://www.google.com',"mytest",'工具栏=否');我的期望是,当它离开我们的登录页面并打开谷歌网站时,后退按钮将被禁用。但事实并非如此。有谁知道为什么吗?

I have a simple logon page. When the user is validated, the window navigates to a new page. The javascript is window.open('http://www.google.com',"mytest",'toolbar=no'); My expectation is that when it navigates away from our logon page and opens the google site that the back button would be disabled. But it's not. Does anyone have any idea why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不喜欢何必死缠烂打 2024-08-24 22:07:16

这取决于您的浏览器。最终,您可以使用 javascript 的 window.open() 做的就是告诉浏览器您希望它做什么,但浏览器没有义务这样做。浏览器可以并且确实会根据用户偏好忽略某些指令。

It depends on your browser. Ultimately, all you can do with javascript's window.open() is tell the browser what you'd like it to do, but it's not obligated to do it. Browsers can and do ignore some directives based on user preferences.

疯了 2024-08-24 22:07:16

我相信您寻找的选项是“location=no”,因为它隐藏了地址栏,因此也隐藏了后退按钮。工具栏是诸如收藏夹之类的东西。

I believe the option your looking for is 'location=no', as that hides the address bar and therefore the back button too. The toolbar is things like favorites/etc.

魄砕の薆 2024-08-24 22:07:16

这是不好的做法 - 如果用户禁用了 javascript 会发生什么?如果浏览器阻止js移除主窗口的工具栏呢?

相反,修改登录页面以在显示登录表单之前检测用户是否已登录。如果登录,则显示一条消息而不是表单 - 这样,用户点击返回就不会出现问题。

当某个网站扰乱我的浏览器窗口并且通常不会再出现时,我觉得非常烦人。

This is bad practice - what happens if the user has javascript disabled? If the browser prevents the js from removing the toolbar of the main window?

Instead, amend the logon page to detect whether the user is logged in before showing the login form. If logged in, show a message saying so instead of the form - that way, a user clicking back won't be a problem.

I find it very annoying when a website messes around with my browser window, and generally don't come back.

你好,陌生人 2024-08-24 22:07:16

这对我有用。而不是禁用后退键。我监听卸载事件。然后我在 javascript 中编写以下内容:

window.onbeforeunload = function () { return "在此应用程序中不应按后退按钮。如果继续,您的工作将不会被保存,您将需要重新登录。"}

Java 脚本会弹出一个对话框,其中包含“确定”和“取消”选项。如果用户点击取消。应用程序保留在原处。该脚本嵌入在标签内。对我来说,这是理想的解决方案。我在

http://www.hunlock.com/blogs/Mastering_The_Back_Button_With_Javascript找到了这个

This is what worked for me. Instead of disabling the back key. I listen for on unload event. I then write the following in javascript:

window.onbeforeunload = function () { return "You should not press the back button while in this application. If you continue, your work will not be saved and you will need to log back in."}

Java Script pops a dialogue box with OK and Cancel options. If the user clicks cancel. The application stays right where they are. The script is embedded within the tags. For me this is the ideal solution. I found this at

http://www.hunlock.com/blogs/Mastering_The_Back_Button_With_Javascript

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文