htmlunit javascript问题 [英] htmlunit javascript question

查看:83
本文介绍了htmlunit javascript问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过网络"以及此处的其他回复进行了浏览.

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

我有一些类似于以下html的内容:

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?? );

类似

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

谢谢

推荐答案

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

type the following into your browser navigation bar:

javascript:alert("hello!")

javascript:alert("hello!")

使用此技术,您可以执行JavaScript命令.对于HtmlUnit,请替换这里发生了什么?".按您将在导航栏中键入的内容(不含"javascript:"部分)

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.

这篇关于htmlunit javascript问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆