View Full Version : java to click a link

12-09-2009, 02:15 AM

so so basically what i wana do is is preform a search in google... easy enough, thats working. what i need to do is to have the last searched link on the page be submited to display via javascript.

essentially what i am doing is creating a "reverse" im feeling lucky button.

i have no clue how to do this, im new to java, however, i was discussing with a friend the possibility of omiting results that started with http://google and searching from the bottom up to obtain the last result?

anyone who was any input on how to get this to work would be appreciated


Philip M
12-09-2009, 09:04 AM
1) This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

2) What you are asking for is not possible using Javascript which cannot communicate with the server.

12-10-2009, 01:44 AM
what i was sorta messing with was something like this

will work for the google search I expect.

document.write('<script type="text/javascript"><!--\n'); document.write('function selectLast(doc) {\n');
document.write(' var links = doc.getElementsByClassName("l");\n');
document.write(' var e = links[links.length-1];\n');
document.write(' return true;\n');

What this function aims to do is retrieve all elements within the document that belong to the class 'l' which is the result class for google links.