0

I'm writing a program that interacts with a website automatically in Java. I figured out how to build and send GET/POST requests to simulate a click or form submit. But I encountered a link that runs a JavaScript function.

<a href="javascript:function()">Run</a>
function function()
{
    document.myform.submit();
}

After clicking, the webpage is redirected to another URL. How do I simulate this behavior in Java?

1
  • what is the function doing? we can't help unless we know what it is doing. Commented Jun 29, 2011 at 15:50

2 Answers 2

2

I've always had the best luck with HTMLUnit. It uses apache http and handles all the interaction pretty intuitively.

Sign up to request clarification or add additional context in comments.

Comments

1

Use an existing library like Selenium or HttpClient to interact with a website.

1 Comment

... or HtmlUnit. It has JavaScript and Dom support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.