简体   繁体   English

在Firefox中创建新标签页/在标签页之间切换?

[英]Creating new tab / switching between Tabs in Firefox?

I am looking for a way to improve the workflow in a PHP based CMS. 我正在寻找一种方法来改善基于PHP的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. 我不想在当前窗口中使用新窗口或iframe来保持工作流程简单并避免混淆。

Is there a way to explicitly open a new tab (not window), and to jump to that tab from a document, in Firefox? 有没有办法在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. 我知道Firefox可能会被迫打开选项卡中的所有链接,但是我认为这不会削减它,因为我仍然无法解决和关注新打开的窗口。

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. 现在,我已经掌握了足够的材料来决定是否要使用油腻的猴子方法,是依靠用户设置“在选项卡中打开”并按名称命名窗口,还是使用许多人建议的“内联” HTML解决方案。 I am accepting the answer that I feel went most effort into. 我接受了我认为已竭尽全力的答案。

There is no way to force a window to open as a tab. 无法强制将窗口作为选项卡打开。 It's all dependent on the user's preference settings. 这完全取决于用户的首选项设置。

You say you don't want to use an iframe to avoid confusion. 您说您不想使用iframe来避免混淆。 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. 现在,我不知道您的网站布局,但是我一直在使用以下方法:编辑器在其自己的div打开,位于要编辑的内容旁边,并且在您编辑时实时更新内容。 No need to change tabs. 无需更改标签。

(If the window is too narrow there are HTML tabs Edit and Preview ) (如果窗口太窄,则存在HTML选项卡EditPreview

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. 在您的情况下,也许值得考虑。

I second the answers that say you should do this in HTML using Javascript. 我第二次回答说您应该使用Javascript在HTML中执行此操作。 Then it can work in all browsers that support JS. 然后,它就可以在所有支持JS的浏览器中使用。

I would put two divs on the page and show/hide each div depending on which tab is selected. 我会在页面上放置两个div,然后根据选择的选项卡显示/隐藏每个div。 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. 单击选项卡的操作是使用AJAX加载远程文档的内容并将其放入选项卡。 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. 在提交AJAX请求之前,请使用Javascript修改URL,以便服务器知道发送网页片段而不是整个页面。

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. 这一切都可以在没有任何浏览器扩展的情况下完成,并且在IE以及Firefox,Opera等环境中也应同样有效。避免将自己锁定在一个浏览器中,即使是与Firefox一样出色的浏览器。 One day a customer will need to use Opera or Safari and you'll be stuck. 有一天,客户需要使用Opera或Safari,您将陷于困境。

What about using iframes and JavaScript? 如何使用iframe和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. 我知道您说过要避免“使用iframe的混乱”,但是我认为如果您确实需要同时加载不同的页面,这是最好的选择。

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 . 从理论上讲,您可以使用javascript甚至使用jQuery创建更好的标签系统,因为它的UI模块提供了非常酷的标签控件

For every tab you could load separate "headerless-footerless" version of your specific admin page inside <iframe> element. 对于每个选项卡,您可以在<iframe>元素内加载特定管理页面的单独的“ headerless-footerless”版本。 If user wanted to modify something different, he will simply click on the tab and bring different iframe. 如果用户想要修改其他内容,则只需点击标签并带来不同的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. 所有这一切也可以使用AJAX来完成,但是iframe解决方案非常容易,因为您只需要加载就绪页面,并且所有回发已由原始页面处理,并与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. 您可能还需要花一点时间来设置iframe的正确高度,以适应所有内容而无需滚动条,但这又只是一点点javascript。

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. 您只能将其设置为打开新窗口,而不能打开新标签。

Greasemonkey springs to mind - a quick google gives open in tabs on left click . 想到Greasemonkey了-一个快速的google会在左键点击的标签中打开 I think you could modify that so it only runs on one particular page, and you'd be up up and away. 我认为您可以对其进行修改,使其仅在一个特定页面上运行,并且您会忙得不可开交。

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). 这个问题使我想知道HTML 5是否允许这种规范,而它不允许 (其他超链接属性之一也没有 )。 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. 新的浏览上下文是新的浏览上下文,无法表达对选项卡在窗口上方还是在背景上方的偏好。

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. 您不能强制使用选项卡,但是如果您使用具有特定名称的目标,例如target =“ my_cms_window”,许多浏览器会将其作为新选项卡打开。 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. 我发现这在现实世界中效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM