Page 1 of 1

Getting a list of web browser elements

PostPosted: Sat Jun 05, 2010 10:19 am
by andybrock
Neobook has a getbrowserelement and setbrowserelement command which is great if you know the names of the elements. Is there any way to load a page and then get a list of all the elements on that web page which can be got or set by the get and set commands?

Andy

PostPosted: Sat Jun 05, 2010 3:58 pm
by Gaev
Andy:

The BrowserGetElement command needs the name of the element whose content you want copied to a [variable].

But elements do not need to be named in order to be rendered by a Browser ... as a result most elements in a typical HTML document are NOT named.

Elements in an HTML document have a hierarchial (parent-children) relationship ... and there are Javascript/DHTML commands to traverse this inverted-tree structure ... while you can ask NeoBook (via the BrowserExecScript command) to execute such commands, you need a good understanding of this structure and the Javascript/DHTML commands in order to do anything beneficial with it.

PostPosted: Sat Jun 05, 2010 10:30 pm
by bunker
Hi I made a simple html example:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Test</title>
<script language="JavaScript">

function GetElements()
{
   for(i=0; i<document.test_form.elements.length; i++)
    {
      alert("Type: " + document.test_form.elements[i].type + " Name: " + document.test_form.elements[i].name);
    }
}   

</script>
</head>
<body>
<form name="test_form" id="test_form" action="#">

Name: <input type="text" name="name" id="txt_name">

Email: <input type="text" name="email" id="txt_email">

<input type="button" name="submit" value="Submit">

</form>
<a href="javascript:GetElements()">Get elements</a>
</body>
</html>


You can modify the javascript so that you return the items in a vector in NeoBook ...

Greetings

PostPosted: Sun Jun 06, 2010 12:51 am
by andybrock
Thank you, that's awesome.

Andy