我正在尝试做一些基本的事情。我只想打开一个新窗口,然后在该窗口中,使用OSX Yosemite的新javascript桥打开2个选项卡。我找不到显示如何执行此操作的文档:
ObjC.import("Cocoa");
chrome = Application("Google Chrome");
chrome.includeStandardAdditions = true
chrome.open("test1tab.com");
chrome.open("test2tab.com");
答案 0 :(得分:2)
我忽略了standardAddiions行,主要是因为我使用它并且在尝试基本蜂鸣声时返回错误()。 另请注意,我必须写出完整的网址才能正常工作!
chrome = Application("Google Chrome");
//chrome.includeStandardAdditions = true;
win = chrome.Window().make();
chrome.windows[0].tabs[0].url = "http://www.crgreen.com/index2.html";
tab = win.tabs.push(new chrome.Tab());
chrome.windows[0].tabs[1].url = "http://www.crgreen.com/boethos/";
(p.s。我编辑了一个垃圾版本,然后看到你原本想要2个标签,所以在这里你去)
答案 1 :(得分:0)
你很亲密。这有效:
chrome = Application("Google Chrome");
chrome.includeStandardAdditions = true;
chrome.openLocation("http://test1tab.com");
chrome.openLocation("http://test2tab.com");
请注意:
ObjC
行是不必要的。openLocation
而不是open
。