1

我正在尝试做一些基本的事情。我只想打开一个新窗口,然后在该窗口中,使用 OSX Yosemite 的新 javascript 桥打开 2 个选项卡。我找不到显示如何执行此操作的文档:

ObjC.import("Cocoa");
chrome = Application("Google Chrome");
chrome.includeStandardAdditions = true
chrome.open("test1tab.com");
chrome.open("test2tab.com");
4

2 回答 2

3

我忽略了 standardAddiions 行,主要是因为我使用了它,并且在尝试基本的 beep() 时它返回了一个错误。另请注意,我必须写出完整的网址才能正常工作!

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/";

(ps我编辑了一个垃圾版本,然后看到你原本想要2个标签,所以你去)

于 2014-12-10T10:45:58.327 回答
0

你很亲密。这有效:

chrome = Application("Google Chrome");
chrome.includeStandardAdditions = true;
chrome.openLocation("http://test1tab.com");
chrome.openLocation("http://test2tab.com");

注意如何:

  • ObjC条线是不必要的。
  • 它必须openLocation代替open.
  • URL 需要指定协议。
于 2018-02-25T14:27:11.670 回答