简体   繁体   中英

Opening a link in a different browser

I'm trying to find a way to take a link from one browser and open it in another browser. This could be taking a link from a Firefox tab and opening it in Chrome, or taking a link in a Chrome Incognito window and opening it in a non-incognito Chrome window.

Here's some more detail. I have a webpage that refreshes every second, and uses javascript(via Greasemonkey/Tampermonkey) to search for certain keywords. When a keyword in my list matches one associated with a link on the page, it automatically opens that link in a new tab. If it's possible, I need to take those links to a different browser somehow, automatically.

AFAIK, something like this isn't possible with javascript due to security issues. The only two solutions I can think of are:

1: Using AutoHotKey to make a macro to copy the link, alt-tab, and paste into the other program. This is manual, I want something automatic. EDIT: I realized I can use AHK to monitor a page, but I don't know if it could be done without introducing more latency than I would like. Keeping the total time from the webpage refreshing to opening the link as low as possible is the most important thing.

2: Having some other program handle it for me. I'm not aware of any and wonder how difficult/costly it would be to roll my own or have someone make one. I'm not even sure if I could interface it with my current script.

I'm fairly certain it would be possible with number 2, although I don't know about cost or difficulty... could there be another way to accomplish this?

For reference, this is the relevant section of code that I'm currently working with. It opens any link which matches a list of keywords in a new tab. These are the links I'm trying to figure out a way to open in a different browser. It uses dynamic object names and a dynamic URL, but essentially this is just saying if the checkboxes are checked and a link matches my autoOpenList(keyword list), then open the link in a new tab.

if(jQuery.inArray(autoOpenTemp,autoOpenList) != -1  && window['autoAccept' + autoOpenTemp].checked && autoAccept_input.checked ){
    var tempURL = LINK_BASE+obj.acc_link;
    window.open(tempURL, '_blank');
}
  1. Use Java's HttpServlet Class to create a web application. You can setup the server by Tomcat. Servlets Quick Guide .
  2. Start CLI by Java and open browser through CLI.
  3. Call the web application by url on your page.

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