htmlunit JavaScript 问题

发布于 2024-08-19 15:25:22 字数 1187 浏览 7 评论 0原文

浏览了“网络”以及这里的其他回复..

我得到了一些类似于以下html的内容:

var langId = '-1';
var demoKey = 'null';
var extraParams = 'null'; // only used for User Registration page
var multiSelect = false;

and

function onCampusSelect_USA() {
    if($('campusUSAIdSelect').value == ''){clearAJAXTimer();hideLayer("programUSADiv");   hideLayer("errorDiv");    hideLayer("buttonDivUS"); return; }
    // REMOVE THIS LATER
    clearAJAXTimer();
    getData(buildParms('PROGRAMSUS','US','campusId='+$('campusUSAIdSelect').value + "&institutionId=" +  $('institutionUSAIdSelect').value));
}

我尝试了以下操作但没有运气

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3);
webClient.setJavaScriptEnabled(true);
HtmlPage page = webClient.getPage("http://www.foo.com/");
ScriptResult scriptResult = page.executeJavaScript("${'multiSelect'}");
System.out.println(scriptResult.getJavaScriptResult());

所以..我试图弄清楚应该做什么在执行行..

ScriptResult scriptResult = page.executeJavaScript( what goes here?? );

类似

document.mutliSelect.value() <<<< (which doesn;t work by the way..)

谢谢

looked through the 'net, as well as other replies on here..

i've got something that looks like the following html:

var langId = '-1';
var demoKey = 'null';
var extraParams = 'null'; // only used for User Registration page
var multiSelect = false;

and

function onCampusSelect_USA() {
    if($('campusUSAIdSelect').value == ''){clearAJAXTimer();hideLayer("programUSADiv");   hideLayer("errorDiv");    hideLayer("buttonDivUS"); return; }
    // REMOVE THIS LATER
    clearAJAXTimer();
    getData(buildParms('PROGRAMSUS','US','campusId='+$('campusUSAIdSelect').value + "&institutionId=" +  $('institutionUSAIdSelect').value));
}

i've tried the following with no luck

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3);
webClient.setJavaScriptEnabled(true);
HtmlPage page = webClient.getPage("http://www.foo.com/");
ScriptResult scriptResult = page.executeJavaScript("${'multiSelect'}");
System.out.println(scriptResult.getJavaScriptResult());

so.. i'm trying to figure out just what should go in the execute line..

ScriptResult scriptResult = page.executeJavaScript( what goes here?? );

something like

document.mutliSelect.value() <<<< (which doesn;t work by the way..)

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

命比纸薄 2024-08-26 15:25:22

在浏览器导航栏中输入以下内容:

javascript:alert("hello!")

使用此技术,您可以执行 JavaScript 命令。对于 HtmlUnit,替换“这里有什么??”通过您在导航栏中输入的内容(不带“javascript:”部分)。

type the following into your browser navigation bar:

javascript:alert("hello!")

Using this technique, you can execute JavaScript commands. For HtmlUnit, replace "what goes here??" by the stuff you would type into the navigation bar without the "javascript:" part.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文