window.open with noopener opening URL in new window despite target=_self - browser

I'm trying to open a window using noopener property and target=_self. Essentially what I want is to open the URL in the same tab while preventing it to have access back to the originating URL.
I'm trying with this syntax:
window.open('http://my-url.com', '_self', 'noopener');
However, this opens the new URL in a new window.
Is there some inherent functionality (maybe the browser back button?) which prevents a URL from opening in the same tab without having access to the previous window ? The docs say nothing about it (https://developer.mozilla.org/en-US/docs/Web/API/Window/open).
Thanks,
Chris

window.open explicitly opens a new window.
You can use location.assign to navigate to a new page in the current window. (Or just use a normal link.)
I guess you’re worried about “tabnabbing”, right? That only applies to windows opened from your page (e.g. using _target=blank or window.open).
Setting noopener has no effect on a normal link that doesn’t open a new window.

I think location.replace() is what you want
window.location.replace("http://my-url.com");
replace() removes the current URL from the document history.
With replace() it is not possible to use "back" to navigate back to the original document.

Related

How to take screenshot of a tab in chrome extension

I am adding screenshot support to my extension, I want to take screenshot of a tab when a specific event is triggered, for example, a url is accessed. Now I am able to take screenshot of current tab using chrome.tabs.capturevisibletab, but the problem is that the event can be triggered by a tab that is not currently visible. So instead of visible tab, how can I take screenshot of any specific tab?
The method name is clear: capturevisibletab.
You can put the focus on the tab you want to snapshot, invoke the method and the restore the focus on the previous tab though.
You will need to add the <all_urls> permission in your manifest file.

How do you get all visible tabs in chrome?

I need to get the tab ids of all VISIBLE tabs in chrome. Note that this is different from currently active tabs or current tab. The user will have the current tab visible, but may have another chrome browser window in the background that may be visible on screen but won't be the current tab. I need the id of that tab as well, and all tabs like it. How can I do this? Can I do this in a way that minimizes permission use (Only using activeTab if possible).
I think that first you have to retrieve all the chrome instances.
you can do this with getAll method.
Then you can loop over all instances and for each look for the active tabs.
there is a SO answer related to this, which may help
You can use chrome.tabs.query.

How to keep extension pop up to remain open when new tab is clicked

my extension close when link in the extension is clicked
How to keep extension pop up to remain open when new tab is clicked
In general, that's not possible as stated in Chrome Extensions FAQ:
Can extensions keep popups open after the user clicks away from them?
No, popups automatically close when the user focuses on some portion of the browser outside of the popup. There is no way to keep the popup open after the user has clicked away.
However, if you inspect the popup, it will stay open as long as you don't close the Developer Tools window.
For end users, the only thing you could do is use a tab instead of a popup if that works better for your use case, or just inject your code into a specific tab to show your interface on top of/next to a page, as some extensions like Siteimprove do.

Sharepoint Open Page in New Tab not Window

I am working on a sharepoint page and want certain links to open in a new tab not a new window. I haven't seen any way to do this other than have server access or doing some invasive coding. I'm not sure of actual version of SP but think it's 2007.
IE version is v8
I checked code in edit mode and can see the target blank bit but as I said it opens in new window not tab.
Thanks
Andrew
_blank option for target param instructs the browser to open hyperlink in either new tab or window. But it depends on browser config or how link has been clicked on (middle click, ctrl+click or normal click) how the link would be opened (new window or new tab).

Hyperlink that opens in a new tab but retain focus on the current/parent page

How do you format HTML A tag (when clicked) to make any browser to open it in a new tag, while retaining the focus on the current/parent page?
I know in Firefox, there is an option that says 'When I Open a link in a new tab, switch to the new tab immediately' .. but I want the opposite of this. When a new tab is opened, do not switch. Regardless I check or uncheck this option, it still behaves as I described above.
Anybody faced this before?
Cheers and thanks in advance for your answers,
Lasker
This is a browser setting and you cannot override this from your code and the main thing is
Don't do this.

Resources