Open several new tabs in JavaScript and get immediate control - javascript

How can I prevent tab opening delay so that I regain control immediately after a single window.open?
Is there any asynchronous window.open like instruction/function available?
Otherwise, how can I emulate the Ctrl+click behavior using Javascript?
… Given the following context …
I have a navigation bar that contains a lot of links pointing to different sections of the application.
One of the big bosses said: «When I click on many of those links the application gets unresponsive»
Which basically mean that he keeps on clicking on those links and then too many tabs suddenly open all at once.
The navigation bar contains links that when clicked trigger the following instruction: window.open(LINK_ADDRESS_HERE, "_blank").
I have noticed that if let's say 6 of those links are clicked within like two seconds, related tabs open as I click on them. But clicking 10 different (navbar) links causes to delay tabs opening, and all of a sudden, the expected tabs finally open, but it takes 3 or more seconds for them to open.
I suspect the user to run too many clicks at the same time and the browser might not handle this.
On the other hand Ctrl+click several links (so they open in a new tab each) on some random sites like StackOverflow doesn't disturb the browser at all and tab opening is not delayed.
In my opinion the issue must come either from my application's JavaScript code or the way window.open works.
Tabs open successfully when only few links have been clicked. But if I click a lot more after the first set of links that have already loaded, at that point this may be either that the application is slow and it takes longer for the new tabs to load, or opened tabs that still load consume the available connections the browser tolerate for a single domain/application (I think that's like 6 connections in HTTP 1.1) and so when new calls to window.open are made, they just wait for a connection slot to be freed. As suche, what I perceive as slow open tabs is due to window.open waiting for available connections.
Thank you.

Related

Manage Chrome Browser Tabs and screen arrangement

I have a use case in which I have to open an URL from Application A which is a SaaS web application. and during it's session Application A can request many URLs to open one by one but all should open in Same Browser Window Tab which was established on first click, in case Browser window is closed accidently next click will open it and subsequent URL request will open in same tab.
Second piece to this is opening on Screen 2 as i have dual monitor setup.
For use case one I was trying something by windows.open and naming that window it works one time next time open two new windows.
Please guide if this is possible? or if any other alternative framework which can help achieve this?

Keep focus on specific tab in Edge

in a last stint to change from EI to Edge, I'm trying to do some focusing that doesn't work like I want it to.
The situation is something like this. Edge is open with several tabs for different pages. One of these pages is an intranet system where the pages contains a link which opens a popup.
In this popup the user has a button where they can create some docx files on a server. To do this, the button calls a new page (subpage1) through javascript (window.open) and the new page again calls another page (subpage2), which finally creates the document.
The later (subpage2) will close (windows.close) it's window on completion.
It all works like it should, with the little annoyance, that the "mother" windows in Edge will switch to the tab to the far right, instead of just staying on the user choosen tab.
Can I control which tab keeps or regains focus when a tab are closed in Edge and if so how?

Chrome extension that communicates with multiple tabs, simultaneously

I am having trouble with making my chrome extension to work with multiple tabs, simultaneously.
The overall flow of my extension is:
Background script opens a new window at the beginning, where the extension js resides.
The extension than injects a js file in the browser's active tab, via executeScript api
In its callback sends a message to this same tab by which my js code performs operations on the tab's DOM
the active tab sends a message to the extension tab
the extension changes the address of the active tab, again via executeScript
background script listens to tabs.onUpdate to determine when the page address changed completed (status === 'complete'), to inject the js in the browser's active tab.
Steps 2-5 go on until a given criteria my extension tab UI defines is met, and the process stops.
This works fine, but I need to leverage this to happen in multiple tabs, simultaneously.
The first idea that pops is to create a number of tabs using tabs.create api, and assuming that simply passing the respective tab ids in the flow above - will work. But it does not.
In the simplest scenario of creating 2 tabs only, the 2 change address at the beginning - but the first tab only does that once. The process goes on with the 2nd tab only.
Is there an inherent problem with the flow above and the "infrastructure" of the extension that cannot accommodate such behavior ?
Am I missing using web workers in the background script - because it synchronize listening to multiple tabs messaging it ?
Any directions would be highly appreciated.

Using window.open repeatedly produces unexpected result

My browser allows any website to show pop-ups (made using window.open).
window.open("http://www.google.com/","_blank");
The above code opens google.com on a new tab.
However, when I use window.open repeatedly like this:
window.open("http://www.google.com/","_blank");
window.open("http://www.facebook.com/","_blank");
window.open("http://www.example.com/","_blank");
Now, google.com is opened on a new tab, while facebook.com and example.com are opened as pop-up windows. I actually want to have the 3 links to open in new tabs but I can't achieve that.
How can I fix this?
I'm surprised the second and third get opened at all. (They don't on Chrome, it blocks them; but I do see the behavior you describe if I disable the blocker.)
You'll need to provide separate UI elements (buttons, whatever) to open each window individually, so that each window.open call is triggered by a separate end-user action, rather than opening several windows in response to a single user action. Hopefully that will give you the behavior you desire for each individual window. Although you don't have control over whether something opens in a new window or a tab, most browsers default to new tabs these days (and most have an option for users to change it) unless you supply the third argument to window.open, in which case they may open a new window instead using the settings you pass in that argument.
Since Chrome does this unusual thing with the second and third calls, limiting yourself to a single open per user action should work in most cases, as in most cases the default is a new tab, not a new window.

link running a javascript that open another page. how to make it do it in new tab if user uses middle click or right click menu

I have this link in my left navigation:
dashboard
That javascript opens a link based on the passed parameters.
All works fine, but I would like to be able to use the browser capabilities of opening the links in a tab (when user is using middle click or selects 'Open link in new tag' from right click menu). Though, this is not working for links handled with javascript code.
There are many reasons why this is not the default behaviour of the browser (e.g. javascript function might only do some validation and stay in the page ... browser can't know what the js might do or if a new window/dialog will result from that action so would make no sense to open new tag as a result of a middle click ...). But hopefully there is a workaround for the default behaviour.
Any idea how this could be done?
Cheers,
Stef.
Javascript links execute in context of the page where they are called. If you "open" the link in a new tab/window, the javascript code will be executed in the new window, i.e., empty, and will most probably fail.
A browser could try to add the feature you are asking for by cloning the page which contains the link, and executing the javascript code in the context of the cloned page. But this would most likely break some critical sites (imagine for example that your online banking site works with javascript, so when you open a link in a new tab/window, cloning the original window might lead to a duplicate transaction).

Categories

Resources