我用脚本编辑器试过这个苹果脚本。 但它不会将我带到手动点击时通常会出现的页面。 它似乎什么都不做:(如何在AppleScript中执行JavaScript函数?
do JavaScript "doCallerPage('FORM_PAGE', 'FR_AN', '/as/an/Check.do');return false;" in document 1
在HTML源链接
<a id="LNK0001" href="javascript:void(0);" onclick="doCallerPage('FORM_PAGE', 'FR_AN', '/as/an/Check.do');return false;">Check Page</a>
JavaScript函数
function doCallerPage(formName, target, actionPath, _action, _t) {
if (actionPath == "") {
return false;
}
if (target && target != "_self") {
checkSubWindow(target);
}
if (document.FORM_PAGE.ctrlflg.value == "") {
if (_action) {
document.FORM_PAGE._ACTION.value = _action;
}
else if (!_action) {
document.FORM_PAGE._ACTION.value = "";
}
}
if (_t) {
document.FORM_PAGE._T.value = _t;
}
else {
document.FORM_PAGE._T.value = "";
}
document.FORM_PAGE.action = actionPath;
document.FORM_PAGE.target = target;
document.FORM_PAGE.submit();
document.FORM_PAGE._P.value = "";
document.FORM_PAGE._T.value = "";
document.FORM_PAGE._ACTION.value = "";
document.FORM_PAGE.ctrlflg.value = "";
}
可能的重复[为什么在JavaScript中调用Applescript时执行相同的代码输入到浏览器执行?](http://stackoverflow.com/questions/6561452/why-doesnt-do-javascript- call-in-applescript-execute-when-the-code-typed) – Barmar
谢谢指出。我之前尝试过。但是它并不适用于我的情况:( – MKK
)基本问题是JavaScript函数只存在于定义它们的页面上下文中,不能仅仅运行一个JavaScript函数本身 – Barmar