在 Firefox 中创建新选项卡/在选项卡之间切换?

发布于 2024-08-13 10:36:16 字数 455 浏览 2 评论 0原文

我正在寻找一种方法来改进基于 PHP 的 CMS 中的工作流程。页面的编辑器模式和预览模式之间有很多切换。编辑器模式的加载量很大,因此我想在不同的窗口中打开预览模式。

我不想在当前窗口中使用新窗口或 iframe 来保持工作流程简单并避免混乱。

有没有办法在 Firefox 中显式打开新选项卡(不是窗口),并从文档跳转到该选项卡? 用户数量有限,因此可以设置具有必要的扩展/权限的客户端。

我知道 Firefox 可以被迫打开选项卡中的所有链接,但我认为这不会解决问题,因为我仍然无法定位和聚焦新打开的窗口。

感谢大家的精彩回答。我现在有足够的材料来决定是否采用 greatmonkey 方法,依靠用户设置“在选项卡中打开”并按名称寻址窗口,或者像你们许多人建议的那样使用“内联”HTML 解决方案。我接受我认为付出了最大努力的答案。

I am looking for a way to improve the workflow in a PHP based CMS. There is a lot of switching between the editor mode and the preview mode of the page. The editor mode is huge to load, and so I would like to open the preview mode in a different window.

I don't want to use new windows or an iframe within the current window to keep the workflow simple and to avoid confusion.

Is there a way to explicitly open a new tab (not window), and to jump to that tab from a document, in Firefox? The number of users is limited, so there is the possibility to set up the client with the necessary extensions / permissions.

I know Firefox can be forced to open all links in tabs, but I think that won't cut it, as I still can't address and focus the newly opened window.

Thanks for all the great answers everyone. I have now enough material to decide whether I'll take the greasemonkey approach, rely on the user to set up "open in tabs" and address the window by name, or use a "inline" HTML solution as so many of you suggested. I am accepting the answer that I feel went most effort into.

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

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

发布评论

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

评论(8

离笑几人歌 2024-08-20 10:36:16

无法强制窗口作为选项卡打开。这完全取决于用户的偏好设置。

There is no way to force a window to open as a tab. It's all dependent on the user's preference settings.

烟柳画桥 2024-08-20 10:36:16

我赞同你应该使用 Javascript 在 HTML 中执行此操作的答案。那么它就可以在所有支持JS的浏览器中运行。

我会在页面上放置两个 div,并根据选择的选项卡显示/隐藏每个 div。如果您对此很聪明,您可以捕获选项卡上的单击并确定用户是左键单击还是中键单击。如果他们左键单击,您将在页面上加载该选项卡。如果他们中键单击,您让浏览器打开一个新选项卡/窗口(根据用户的首选项,不要尝试强制它),并保持当前窗口不变(即,不要切换到新选项卡) 。单击选项卡的操作是使用 AJAX 加载远程文档的内容并将其放入选项卡中。在提交 AJAX 请求之前使用 Javascript 修改 URL,以便服务器知道发送网页片段而不是整个页面。

这种双重性质解决方案的优点是,选项卡式方法将在大多数情况下按照您希望的方式工作,但对于拥有两个屏幕或喜欢在浏览器选项卡之间切换的用户来说,他们仍然可以在多窗口模式下工作的灵活性。这一切都可以在没有任何浏览器扩展的情况下完成,并且它在 IE 以及 Firefox、Opera 等中应该同样有效。避免将自己锁定在一种浏览器中,即使是像 Firefox 这样优秀的浏览器。有一天,客户需要使用 Opera 或 Safari,而您就会陷入困境。

I second the answers that say you should do this in HTML using Javascript. Then it can work in all browsers that support JS.

I would put two divs on the page and show/hide each div depending on which tab is selected. If you are clever about this you could trap the click on the tab and determine if the user left-clicked or middle-clicked. If they left click you load that tab on the page. If they middle-click you let the browser open a new tab/window (according to the user's prefs, don't try to force it), and leave the current window unchanged (that is, don't switch to the new tab). The action for clicking on the tab would be to use AJAX to load the contents of the remote document and put it into the tab. Use Javascript to modify the URL before submitting the AJAX request so that the server knows to send a web page fragment instead of the whole page.

The advantage of this dual-natured solution is that the tabbed approach will work the way you want it to work for the majority of cases, but for users with, say, two screens, or who prefer switching between browser tabs, they will still have the flexibility to work in multi-window mode. This can all be done without any browser extensions and it should work equally well in IE as well as Firefox, Opera, etc. Avoid locking yourself into one browser, even one as excellent as Firefox. One day a customer will need to use Opera or Safari and you'll be stuck.

昇り龍 2024-08-20 10:36:16

您说您不想使用 iframe 以避免混淆。现在我不知道您网站的布局,但我一直在使用编辑器在正在编辑的内容旁边的自己的 div 中打开的方法,并且内容正在实时更新当你编辑时。无需更改选项卡。

(如果窗口太窄,则有 HTML 选项卡编辑预览

它似乎不会给用户带来困惑,对我来说,这种方法非常有效。也许就你的情况值得考虑。

You say you don't want to use an iframe to avoid confusion. Now I don't know about the layout of your website, but I've been using the approach that the editor opens in its own div right next to the content being edited and the content is being live updated as you edit. No need to change tabs.

(If the window is too narrow there are HTML tabs Edit and Preview)

It does not seem to add confusion to the user and for me this approach works really well. Maybe it's worth considering in your case.

萌吟 2024-08-20 10:36:16

使用 iframe 和 JavaScript 怎么样?

我知道你说过你想避免“使用 iframe 造成混乱”,但在我看来,如果你确实需要同时加载不同的页面,这是最好的选择。

理论上,您可以使用 javascript 创建自己的选项卡系统,甚至使用 jQuery 更好,因为它的 UI 模块提供了非常酷的 选项卡控件

对于每个选项卡,您可以在 元素中加载特定管理页面的单独“headerless-footerless”版本。如果用户想要修改不同的内容,他只需单击选项卡并带来不同的 iframe。

所有这些也可以使用 AJAX 来完成,但 iframe 解决方案非常简单,因为您只需要加载准备好的页面,并且所有回发都已由原始页面处理并与主管理页面分开。

您可能还需要花一点时间来设置 iframe 的正确高度,以适应所有没有滚动条的内容,但这又只是一点 JavaScript。

What about using iframes and JavaScript?

I know you said you want to avoid 'confusion using iframes', but in my opinion if you really need to load different pages at the same time this is the best option.

In theory, you could create your own tab system using javascript or even better, using jQuery, because its UI module offers pretty cool tab control.

For every tab you could load separate "headerless-footerless" version of your specific admin page inside <iframe> element. If user wanted to modify something different, he will simply click on the tab and bring different iframe.

All this could also be done using AJAX, but iframe solution is quite easy as you just need to load ready page and all postbacks are already handled by original page and separated from master-admin-page.

You might also need to play a little bit to set correct height of your iframe to fit all the content without scrollbars, but this again, is just bit of javascript.

走过海棠暮 2024-08-20 10:36:16

不,没有办法强制打开新选项卡,因为非选项卡式浏览不支持此操作

您只能将其设置为打开新窗口,而不能设置新选项卡。

Nope, there's no way to force the opening of a new tab, simply because this would be unsupported by un-tabbed browsing

You can only set it to open a new window, not a new tab.

菩提树下叶撕阳。 2024-08-20 10:36:16

Greasemonkey 浮现在脑海中 - 快速谷歌给出左键单击在选项卡中打开。我认为您可以对其进行修改,使其仅在一个特定页面上运行,然后您就可以离开了。

Greasemonkey springs to mind - a quick google gives open in tabs on left click. I think you could modify that so it only runs on one particular page, and you'd be up up and away.

若水微香 2024-08-20 10:36:16

这个问题让我想知道 HTML 5 是否允许这种规范,并且 它没有(其他之一中没有任何内容超链接属性,或者)。新的浏览上下文就是新的浏览上下文,无法表达选项卡优先于窗口或前景优先于背景的偏好。

This question made me wonder if HTML 5 allows that sort of specification, and it doesn't (nothing in one of the other hyperlink attributes, either). A new browsing context is a new browsing context, there's no way to express a preference for tab over window or foreground over background.

饮惑 2024-08-20 10:36:16

您无法强制打开选项卡,但如果您使用具有特定名称的目标,例如 target="my_cms_window",许多浏览器会将其作为新选项卡打开。此外,他们会记住名称,如果您重复使用目标,请将内容放在同一选项卡中。我发现这在现实世界中效果很好。

You can't force a tab, but if you use a target with a specific name, like target="my_cms_window", many browsers will open this as a new tab. Additionally, they will remember the name and if you use the target repeatedly, put the contents in the same tab. I have found that this works pretty well in the real world.

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