简体   繁体   中英

Chrome Extension to open URL in another window in Incognito mode

I am from Siebel developer background. Dont have exposure/any kind of work experience with web development/chrome.extensions. For one of the requirement I need to open multiple sieble sessions on clicking a custom button in the application. There is limitation that multiple sessions can't be supported with current siebel product version we are using.

Hence trying to leverage the chrome extension option over here. With the other stackoverflow postings, have created a basic extension. Below are the manifest.json and eventPage.js files.

 { "name": "Open new window", "version": "1.0", "manifest_version": 2, "description": "Opens new window", "background": { "scripts": ["eventPage.js"], "persistent": false }, "browser_action": { "default_title":"Message!" }, "permissions": ["tabs", "<all_urls>"] } 

 eventPage.js chrome.extension.onMessage.addListener( function(request, sender, sendResponse) { if (request.action == "openNewTab") chrome.tabs.create({ url: request.url, "incognito": true}); } ); 

From the Siebel application, trying to call chrome.extension, but running into issues. Below is calling script.

 $("#siebelUIButton").click(function sendMessage() { chrome.extension.sendMessage({ action: "openNewTab", url: "www.google.com" }); }); 

I am sure that code written doesn't makes sense, requesting your help and guidance to overcome the issue.

Thanks Kumar

Not sure I follow the question. Sounds like you want to open a URL from a background script into a new tab. You can call this from a content script (no need for a background script). This will open the URL into a tab from the content script. Where URL is your http:// URL string, where rptTab is open same browser tab when this 'button' is selected...

var win = window.open(url, 'rptTab');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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