10 examples of 'window.open in same tab' in JavaScript

Every line of 'window.open in same tab' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
17open(file: FSNode, asnew: boolean) { if(!asnew) this.file = file; }
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

667export async function openTabInWindow(tab, options = {}) {
668 if (options.multiselected !== false && tab.$TST.multiselected) {
669 return openTabsInWindow(Tab.getSelectedTabs(tab.windowId));
670 }
671 else {
672 const window = await browser.windows.create({
673 tabId: tab.id,
674 incognito: tab.incognito
675 }).catch(ApiTabs.createErrorHandler());
676 return window.id;
677 }
678}
14function open_in_new_tab(url )
15{
16 var win=window.open(url, '_blank');
17 win.focus();
18}
1function openintab(url) {
2 var togo = window.location.protocol + "//" + window.location.host + "/editor?uuid=" + url + "&profile=jbpm&pp=";
3 window.open(togo, '_blank');
4}
120function openTabOrWindow(url)
121{
122 try {
123 var gBrowser = window.opener.getBrowser();
124 gBrowser.selectedTab = gBrowser.addTab(url);
125 }
126 catch (e) {
127 window.open(url);
128 }
129}
9function open_tab(url, mode) {
10 action = {"createProperties":{"url":url},"mode":mode};
11 if(mode == "newtab")
12 action.createProperties.active = false;
13 chrome[runtimeOrExtension].sendMessage(action);
14}
50open_tab ({ label, description, category, position = 'next' } = {}, view) {
51 const id = `${category}-${view.id}`;
52 const add_tab = () => this.$$tablist.add_tab(id, label, description || label, $tabpanel, position);
53 let page;
54 let pages = BzDeck.views.pages[`${category}_list`];
55 let $tab = document.querySelector(`#tab-${CSS.escape(id)}`);
56 let $tabpanel = document.querySelector(`#tabpanel-${CSS.escape(id)}`);
57
58 if (!pages) {
59 pages = BzDeck.views.pages[`${category}_list`] = new Map();
60 }
61
62 // Reuse a tabpanel if possible
63 if ($tabpanel) {
64 page = pages.get(view.id);
65 $tab = $tab || add_tab();
66 } else {
67 page = view;
68 pages.set(view.id, page);
69 $tabpanel = this.get_template(`tabpanel-${category}-template`, view.id);
70 $tab = add_tab();
71
72 // Prepare the Back button on the mobile banner
73 BzDeck.views.global.add_back_button($tabpanel);
74 }
75
76 BzDeck.views.global.update_window_title($tab);
77 BzDeck.views.pages[category] = page;
78 this.tab_path_map.set($tab.id, location.pathname + location.search);
79 this.$$tablist.view.selected = this.$$tablist.view.$focused = $tab;
80 $tabpanel.focus();
81}
17function openAndCloseTab(url) {
18 chrome.tabs.create({ url }, tab => {
19 const removeTab = () => {
20 chrome.windows.onFocusChanged.removeListener(removeTab);
21 if (tab && tab.id) {
22 chrome.tabs.remove(tab.id, () => {
23 if(chrome.runtime.lastError) console.log(chrome.runtime.lastError); // eslint-disable-line no-console
24 else if (chrome.devtools && chrome.devtools.inspectedWindow) {
25 chrome.tabs.update(chrome.devtools.inspectedWindow.tabId, {active: true});
26 }
27 });
28 }
29 };
30 if (chrome.windows) chrome.windows.onFocusChanged.addListener(removeTab);
31 });
32}
23function openTab(url) {
24 console.log('create OpenNewTab Func for ', url);
25 url = chrome.extension.getURL(url)
26 return function (tab){
27 console.log('EVENT click browserAction', tab, arguments);
28 var createProperties = {
29 url:url
30 };
31 chrome.tabs.create(createProperties, function () {
32 console.log('EVENT new browserAction - windowOpen', arguments);
33 });
34 }
35};
137function switchToExistingNewTab (payload, state, send, done) {
138 if (payload && payload.url) return
139
140 const all = listOfTabs(state)
141 let existing
142
143 for (let tab of all) {
144 if (!tab.isNew) continue
145 existing = tab
146 break
147 }
148
149 if (!existing) return
150
151 select(existing.id, state, send, done)
152 send('search:open', { query: '' }, done)
153 return true
154}

Related snippets