简体   繁体   English

从外部程序定位相同的浏览器选项卡

[英]Targeting same browser tab from an external program

We are opening a webpage when a user clicks a button from an external program (non-web). 当用户点击外部程序(非网络)中的按钮时,我们正在打开网页。 The problem is, when the user goes back to the program and opens another one, it opens in the same browser window but a different tab. 问题是,当用户返回程序并打开另一个程序时,它会在同一浏览器窗口中打开,但会打开另一个选项卡。 After a few hours of this, our non-tech savvy clients have 30+ tabs open which really slows down their computer. 几个小时后,我们的非技术精明的客户打开了30多个标签,这真的会减慢他们的电脑速度。

The language we are using in the external program is RPG (IBM iSeries). 我们在外部程序中使用的语言是RPG(IBM iSeries)。 We haven't found a way to target the same tab from RPG. 我们还没有找到一种方法来从RPG中定位相同的标签。 The user is sitting at a specialized telnet session called 5250 where the server program (RPG) can call exe's on the connected PC. 用户正坐在名为5250的专用telnet会话中,其中服务器程序(RPG)可以在连接的PC上调用exe。 It can also call URL's and that will use the client's default web browser. 它也可以调用URL,并使用客户端的默认Web浏览器。 When doing this the only real parameter you can specify is the URL itself, so we're thinking the solution needs to be entirely in the browser. 执行此操作时,您可以指定的唯一真实参数是URL本身,因此我们认为解决方案需要完全在浏览器中。 We could write an exe to call the browser, but that would defeat the purpose of migrating these to web apps. 我们可以编写一个exe来调用浏览器,但这会破坏将这些迁移到Web应用程序的目的。

Is there a way to achieve this with HTML/JavaScript/PHP/etc? 有没有办法用HTML / JavaScript / PHP /等实现这个目标? We have tried having the external program call a redirect script (JavaScript) that will target a browser tab and then close itself. 我们已经尝试让外部程序调用一个重定向脚本(JavaScript),该脚本将以浏览器选项卡为目标,然后自行关闭。 This would be a great solution if browsers weren't so picky with security. 如果浏览器不那么挑剔安全性,这将是一个很好的解决方案。

Firefox: has a special setting you have to set so JavaScript can close the tab IE: won't open the popup until the user picks 'allow popups from this domain'. Firefox:有一个特殊的设置,你必须设置,以便JavaScript可以关闭选项卡IE:在用户选择“允许来自此域的弹出窗口”之前不会打开弹出窗口。 but the original tab closes itself before the user gets to do this. 但是在用户执行此操作之前,原始选项卡会自行关闭。 Chrome: Chrome kills the reference to the named tab. Chrome:Chrome会杀死对指定标签的引用。 So, each new popup opens in a new tab anyway (even though they are calling the same target name). 因此,无论如何,每个新弹出窗口都会在新选项卡中打开(即使它们调用相同的目标名称)。

We have been getting really creative with this but haven't come up with a solid solution. 我们已经变得非常有创意但没有提出可靠的解决方案。 This is an intranet project, but we'd like to avoid having to install or set things on each computer due to the sheer number of PCs at these companies. 这是一个内联网项目,但由于这些公司的PC数量庞大,我们希望避免在每台计算机上安装或设置东西。

In a nutshell, the main issue is the second RPG opens a new window, that new window doesn't have any reference to previously opened named tabs. 简而言之,主要问题是第二个RPG打开一个新窗口,新窗口没有任何对以前打开的命名选项卡的引用。

I'm a bit thinking out of the box here mainly because I have no idea how your programs work. 我在这里开箱即用,主要是因为我不知道你的程序是如何运作的。 To start of, there is literally no way to close a X-tab, where x is the tab you want. 首先,实际上没有办法关闭X-tab,其中x是你想要的标签。 The only way is to actually be in that tab/page to close it. 唯一的方法是实际在该选项卡/页面中关闭它。 That's with PHP, HTML, JS etc. I assume you can achieve it with some C++/C# or whatever runs on your "client" rather than browser. 这与PHP,HTML,JS等有关。我假设您可以使用某些C ++ / C#或在“客户端”而不是浏览器上运行的任何内容来实现它。

Now, the out of the box possible solution is to have some session management and an ajax call. 现在,开箱即用的解决方案是进行一些会话管理和ajax调用。 My suggestion is to create a new session on a new tab. 我的建议是在新标签上创建一个新会话。 User gets a new tab, you give it number 1. Every x-seconds you do a ajax call to a script, which simply checks what "tab" it is. 用户获得一个新标签,你给它编号1.你每隔x秒就对一个脚本进行ajax调用,它只是检查它是什么“标签”。 Let me give an example. 让我举个例子。

User opens a new tab, session is started and you have an array with the following: 用户打开一个新选项卡,会话启动,您有一个包含以下内容的数组:

$_SESSION['tabs'][1] = 'set';

Now this tab keeps doing calls to a file, to see if it should stay "alive". 现在,此选项卡不断调用文件,以查看它是否应保持“活动”状态。 Basically you post with "Hi, I'm tab 1". 基本上你用“嗨,我是标签1”发帖。 When you check the session, tab 1 should be the only 1 there. 检查会话时,选项卡1应该是唯一的1。

On a new tab, the session tabs gets an other value, named "2" which gets set. 在新选项卡上,会话选项卡获取另一个名为“2”的值,该值已设置。 Now when tab 1 posts to the ajax caller, it should give a message back that it can be closed. 现在,当标签1发布到ajax调用者时,它应该回复一条消息,它可以被关闭。 When it receives that message it should invoke some JS like: 当它收到该消息时,它应该调用一些JS,如:

javascript:window.open('','_self').close();

This is just thinking out loud, I guess the basic idea should work, tho I have never tested it nor can I give you a full code example. 这只是大声思考,我想基本的想法应该有用,因为我从未测试过它,也不能给你一个完整的代码示例。 Perhaps when I got some spare time I could try to create this. 也许当我有空闲时间时,我可以尝试创造这个。

If you name a frame in target that doesn't exist, it will open up in a new tab. 如果在目标中命名一个不存在的框架,它将在新选项卡中打开。 Use the same frame name, it will continue to use that tab. 使用相同的框架名称,它将继续使用该选项卡。

Have you considered creating a quick Handoff application that is called from the RPG rogram to handle the browser request? 您是否考虑过创建一个从RPG rogram调用以处理浏览器请求的快速Handoff应用程序? This will allow you to specify that the same tab should be used when a new request is made as well as sending specific parameters for customization. 这将允许您指定在发出新请求时应使用相同的选项卡,以及发送用于自定义的特定参数。 See this response from Karl Anderson ==> Reusing browser/tab in VB.net 请参阅Karl Anderson的回复==> 重用VB.net中的浏览器/标签

similar code below: 类似的代码如下:

Private Sub ToUrl(ByVal url As String, ByVal strDocType As String, ByVal strSSN As String)
        Dim IE As SHDocVw.InternetExplorer
        IE = GetTopmostInstanceOfCustomApp() ' Get the topmost instance of custom app (will return new instance if not running)
        If Not IE Is Nothing Then
            Dim Header As String = "Content-Type: application/x-www-form-urlencoded" & Chr(10) & Chr(13)
            SetForegroundWindow(IE.HWND)
            url = url & strCustomParameter
            IE.Navigate2(url, , , , Header)
        End If
End Sub

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

相关问题 单击来自外部源的事件会导致浏览器选项卡重置 - Clicking an event from external source causes browser tab to reset 通过外部程序在Firefox(或任何其他浏览器)中触发Javascript函数 - Trigger Javascript function in Firefox (or any other browser) from an external program 来自浏览器选项卡的实时转录 - Livetrabscription from browser tab 如何检查用户是在一个选项卡上登录该站点而不是在同一浏览器中的另一个选项卡上? - How can you check if a user is logged into the site on one tab but not on another tab from the same browser? jQuery UI选项卡:通过链接定位动态选项卡 - jQuery UI Tabs: Targeting Dynamic Tab from a Link 强制外部链接(来自我的网站)在该设备的默认浏览器中的新标签页中打开? - Force external links (from my website) to open in a new tab within the default browser for that device? 浏览器在外部程序中打开text / xml - Browser opening text/xml in external program 外部程序中的javascript打开链接,而不是浏览器 - javascript open link in external program instead browser 在同一新标签页中打开外部链接 - Opening external links in the same new tab 如何从另一个标签中选择浏览器标签? - How to select a browser tab from another tab?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM